nextload/Dockerfile

47 lines
997 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
2024-06-20 08:37:21 +00:00
WORKDIR /base
2024-06-14 20:35:28 +00:00
2024-06-20 08:37:21 +00:00
2024-06-23 08:32:21 +00:00
# Local Development
2024-06-20 08:37:21 +00:00
FROM base AS dev
ENTRYPOINT []
CMD ["pnpm", "dev:next"]
# Production
FROM base AS builder
2024-06-23 08:32:21 +00:00
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
2024-06-23 08:32:21 +00:00
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
2024-06-20 08:37:21 +00:00
ENV NODE_ENV=production
2024-06-23 08:42:27 +00:00
RUN pnpm generate:types
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"]