2024-06-14 20:35:28 +00:00
|
|
|
# Build stage
|
|
|
|
FROM node:20-slim as builder
|
2024-06-05 20:41:46 +00:00
|
|
|
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
|
|
RUN corepack enable
|
|
|
|
|
2024-06-14 20:35:28 +00:00
|
|
|
|
|
|
|
WORKDIR /builder
|
2024-06-05 20:33:56 +00:00
|
|
|
COPY package.json pnpm-lock.yaml ./
|
2024-06-16 18:49:02 +00:00
|
|
|
RUN pnpm install --frozen-lockfile
|
2024-06-05 20:25:53 +00:00
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
2024-06-06 06:19:41 +00:00
|
|
|
|
2024-06-14 20:35:28 +00:00
|
|
|
COPY . .
|
|
|
|
|
2024-06-05 20:31:53 +00:00
|
|
|
RUN pnpm build
|
2024-06-05 20:25:53 +00:00
|
|
|
|
2024-06-06 06:05:16 +00:00
|
|
|
# Production stage: serve the application
|
2024-06-14 20:35:28 +00:00
|
|
|
FROM node:20-slim as runner
|
|
|
|
WORKDIR /runner
|
2024-06-06 06:05:16 +00:00
|
|
|
|
2024-06-14 20:35:28 +00:00
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
2024-06-06 06:19:41 +00:00
|
|
|
RUN corepack enable
|
2024-06-05 20:25:53 +00:00
|
|
|
|
2024-06-14 20:35:28 +00:00
|
|
|
## Copy build artifacts from the build stage
|
|
|
|
COPY --from=builder /builder/package.json ./
|
|
|
|
#COPY --from=builder /builder/node_modules ./node_modules
|
|
|
|
COPY --from=builder /builder/.next/standalone ./.next/standalone/
|
2024-06-16 18:49:02 +00:00
|
|
|
COPY --from=builder /builder/.next/static ./.next/standalone/.next/static
|
2024-06-19 19:49:09 +00:00
|
|
|
#COPY --from=builder /builder/public ./.next/standalone/.next/public
|
2024-06-14 20:35:28 +00:00
|
|
|
COPY --from=builder /builder/next.config.mjs ./
|
2024-06-06 06:05:16 +00:00
|
|
|
|
2024-06-15 11:14:39 +00:00
|
|
|
FROM runner as server
|
2024-06-05 20:25:53 +00:00
|
|
|
EXPOSE 3000
|
2024-06-18 21:44:01 +00:00
|
|
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
2024-06-14 20:35:28 +00:00
|
|
|
CMD ["pnpm", "start:standalone"]
|