feat: add Docker support with multi-stage build, compose configuration, and standalone output mode

This commit is contained in:
Michael committed 2026-04-10 10:01:55 +02:00
1 parent b73aa8616b
commit 6c0aef1d88
5 files changed
+108 -1

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
# Stage 1: Build
FROM node:20-bookworm-slim AS builder
WORKDIR /app
# Install build dependencies for better-sqlite3 and bcrypt
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package*.json ./
COPY prisma ./prisma/
RUN npm install
COPY . .
# Generate Prisma Client (crucial for standalone)
RUN npx prisma generate
# Build Next.js app
RUN npm run build
# Stage 2: Runner
FROM node:20-bookworm-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Install runtime dependencies for SQLite
RUN apt-get update && apt-get install -y \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Copy standalone build and static files
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
# Expose port
EXPOSE 3214
# Set up entrypoint script
COPY entrypoint.sh ./
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]