38 lines
893 B
Docker
38 lines
893 B
Docker
# Build stage
|
|
FROM node:20-slim as builder
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
|
|
WORKDIR /builder
|
|
COPY package.json pnpm-lock.yaml ./
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
COPY . .
|
|
|
|
RUN pnpm build
|
|
|
|
# Production stage: serve the application
|
|
FROM node:20-slim as runner
|
|
WORKDIR /runner
|
|
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
RUN corepack enable
|
|
|
|
## 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/
|
|
COPY --from=builder /builder/.next/static ./.next/static
|
|
COPY --from=builder /builder/public ./public
|
|
COPY --from=builder /builder/next.config.mjs ./
|
|
|
|
#FROM runner as server
|
|
EXPOSE 3000
|
|
CMD ["pnpm", "start:standalone"]
|