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:23:19 +01:00
|
|
|
COPY --from=builder /app/public ./public
|
|
|
|
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
2023-10-15 04:27:37 +01:00
|
|
|
COPY --from=builder /app/next.config.js ./
|
|
|
|
COPY --from=builder /app/.next/standalone ./
|
|
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
COPY --from=builder /app/public ./.next/static
|
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
|
|
|
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
|