36 lines
799 B
Docker
36 lines
799 B
Docker
ARG BASE_IMAGE=node:17.9-alpine
|
|
|
|
# Dependancy Stage
|
|
FROM $BASE_IMAGE AS dependancies
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Source Code Stage
|
|
FROM $BASE_IMAGE AS builder
|
|
WORKDIR /app
|
|
COPY --from=dependancies /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
|
RUN npm run build
|
|
|
|
# Production Image Stage
|
|
FROM $BASE_IMAGE AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/package.json ./package.json
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
ENV PORT 3000
|
|
|
|
CMD ["node", "server.js"] |