2023-10-15 04:07:36 +01:00
|
|
|
FROM fascinated/docker-images:node-pnpm-latest AS base
|
2023-10-15 03:59:34 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
# Install depends
|
|
|
|
FROM base AS deps
|
|
|
|
RUN apk add --no-cache libc6-compat
|
2022-10-26 12:15:56 +01:00
|
|
|
WORKDIR /app
|
2023-10-15 04:07:36 +01:00
|
|
|
COPY package.json* pnpm-lock.yaml* ./
|
|
|
|
RUN pnpm install --production --frozen-lockfile --quiet
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
# Build from source
|
|
|
|
FROM base AS builder
|
2022-10-29 16:05:29 +01:00
|
|
|
WORKDIR /app
|
2022-10-29 16:09:03 +01:00
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
2022-10-29 16:05:29 +01:00
|
|
|
COPY . .
|
2022-10-26 12:28:48 +01:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2023-10-15 04:07:36 +01:00
|
|
|
RUN pnpm build
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
# Run the app
|
|
|
|
FROM base AS runner
|
2022-10-26 12:15:56 +01:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ENV NODE_ENV production
|
2022-10-26 13:02:09 +01:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
RUN mkdir .next
|
|
|
|
RUN chown nextjs:nodejs .next
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:07:36 +01:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
2022-10-26 12:15:56 +01:00
|
|
|
|
2023-10-15 04:16:35 +01:00
|
|
|
RUN npm i -g @beam-australia/react-env
|
2022-10-29 16:13:45 +01:00
|
|
|
|
2022-10-26 12:15:56 +01:00
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
2023-10-15 04:07:36 +01:00
|
|
|
ENV HOSTNAME "0.0.0.0"
|
2022-10-26 12:15:56 +01:00
|
|
|
ENV PORT 3000
|
2023-10-15 04:07:36 +01:00
|
|
|
CMD npx react-env --env APP_ENV && pnpm start
|