Files
Todo/Dockerfile

49 lines
1.2 KiB
Docker

# Use Node.js LTS version
FROM node:20-slim AS base
# Install dependencies only when needed
FROM base AS deps
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies but skip Prisma postinstall
RUN npm install --ignore-scripts
# Rebuild the source code only when needed
FROM base AS builder
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma Client for the correct platform (Debian)
RUN npx prisma generate --generator client
# Don't build for development mode
ENV NEXT_TELEMETRY_DISABLED 1
ENV AUTH_TRUST_HOST true
# Production image, copy all the files and run next
FROM base AS runner
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy all files from builder
COPY --from=builder --chown=nextjs:nodejs /app ./
USER nextjs
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
CMD ["npm", "run", "dev"]