nextload/Dockerfile

46 lines
967 B
Docker
Raw Normal View History

2024-06-14 20:35:28 +00:00
# Build stage
2024-06-20 08:37:21 +00:00
FROM node:20-slim as base
2024-06-05 20:41:46 +00:00
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
2024-06-20 08:37:21 +00:00
WORKDIR /base
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
2024-06-14 20:35:28 +00:00
COPY . .
2024-06-20 08:37:21 +00:00
# Development
FROM base AS dev
ENTRYPOINT []
CMD ["pnpm", "dev:next"]
# Production
FROM base AS builder
ENV NODE_ENV=production
2024-06-05 20:31:53 +00:00
RUN pnpm build
2024-06-05 20:25:53 +00:00
2024-06-20 08:37:21 +00:00
# Production: copy build artifacts
2024-06-14 20:35:28 +00:00
FROM node:20-slim as runner
2024-06-20 08:37:21 +00:00
WORKDIR /prod
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-20 08:37:21 +00:00
COPY --from=builder /base/package.json ./
COPY --from=builder /base/.next/standalone ./.next/standalone/
COPY --from=builder /base/.next/static ./.next/standalone/.next/static
COPY --from=builder /base/public ./.next/standalone/public
COPY --from=builder /base/next.config.mjs ./
2024-06-06 06:05:16 +00:00
2024-06-20 08:37:21 +00:00
# Production: serve the website
FROM runner as prod
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"]