2022-04-13 18:31:38 -04:00
|
|
|
FROM node:17-alpine AS deps
|
|
|
|
|
2022-03-07 23:42:44 -05:00
|
|
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
|
|
|
RUN apk add --no-cache libc6-compat
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-07 23:42:44 -05:00
|
|
|
WORKDIR /app
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-07 23:42:44 -05:00
|
|
|
COPY package.json yarn.lock ./
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-07 23:42:44 -05:00
|
|
|
RUN yarn install --frozen-lockfile
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
FROM node:17-alpine AS builder
|
2022-03-07 23:42:44 -05:00
|
|
|
|
|
|
|
WORKDIR /app
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-07 23:42:44 -05:00
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
COPY . .
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ARG API_URL
|
|
|
|
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
ENV API_URL=${API_URL:-http://localhost:3000}
|
2022-03-07 23:42:44 -05:00
|
|
|
|
|
|
|
RUN yarn build
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
FROM node:17-alpine AS runner
|
2022-03-07 23:42:44 -05:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ARG NODE_ENV
|
2022-03-07 23:42:44 -05:00
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
ENV NODE_ENV=${NODE_ENV:-production}
|
2022-03-07 23:42:44 -05:00
|
|
|
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
|
2022-03-28 22:26:16 -04:00
|
|
|
COPY --from=builder /app/next.config.mjs ./
|
2022-03-07 23:42:44 -05:00
|
|
|
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
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ENV PORT=3001
|
2022-03-07 23:42:44 -05:00
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
EXPOSE 3001
|
2022-03-07 23:42:44 -05:00
|
|
|
|
|
|
|
CMD ["node", "server.js"]
|