2023-10-15 03:07:36 +00:00
|
|
|
FROM fascinated/docker-images:node-pnpm-latest AS base
|
2023-10-15 02:59:34 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Install depends
|
|
|
|
FROM base AS deps
|
|
|
|
RUN apk add --no-cache libc6-compat
|
2022-10-26 11:15:56 +00:00
|
|
|
WORKDIR /app
|
2023-10-15 03:07:36 +00:00
|
|
|
COPY package.json* pnpm-lock.yaml* ./
|
|
|
|
RUN pnpm install --production --frozen-lockfile --quiet
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Build from source
|
|
|
|
FROM base AS builder
|
2022-10-29 15:05:29 +00:00
|
|
|
WORKDIR /app
|
2022-10-29 15:09:03 +00:00
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
2022-10-29 15:05:29 +00:00
|
|
|
COPY . .
|
2022-10-26 11:28:48 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2023-10-15 03:07:36 +00:00
|
|
|
RUN pnpm build
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Run the app
|
|
|
|
FROM base AS runner
|
2022-10-26 11:15:56 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ENV NODE_ENV production
|
2022-10-26 12:02:09 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:23:19 +00: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 03:27:37 +00: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 11:15:56 +00:00
|
|
|
|
2023-10-15 03:16:35 +00:00
|
|
|
RUN npm i -g @beam-australia/react-env
|
2022-10-29 15:13:45 +00:00
|
|
|
|
2022-10-26 11:15:56 +00:00
|
|
|
EXPOSE 3000
|
2023-10-15 03:07:36 +00:00
|
|
|
ENV HOSTNAME "0.0.0.0"
|
2022-10-26 11:15:56 +00:00
|
|
|
ENV PORT 3000
|
2023-10-15 03:07:36 +00:00
|
|
|
CMD npx react-env --env APP_ENV && pnpm start
|