All checks were successful
Build & Deploy / build (push) Successful in 1m22s
48 lines
1.3 KiB
Docker
48 lines
1.3 KiB
Docker
# ---- Dependencies ----
|
|
FROM node:20-alpine AS deps
|
|
WORKDIR /app
|
|
RUN apk add --no-cache openssl
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# ---- Builder ----
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
RUN apk add --no-cache openssl
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN mkdir -p public
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# ---- Runner ----
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
RUN apk add --no-cache openssl
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy standalone output
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Copy prisma for migrations
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
|
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
|
|
COPY --from=builder /app/node_modules/.bin/prisma ./node_modules/.bin/prisma
|
|
|
|
# Entrypoint script
|
|
COPY docker-entrypoint.sh ./
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"] |