opennextjs-opennextjs-aws
SUCCESS
18m 33s
History Source
SummaryIterations1Transcript9Dockerfile
Dockerfile32 lines · 1119 chars
# Multi-stage Dockerfile to build and run the OpenNext AWS package from source

# Builder stage: install dependencies and build from source
FROM node:20.9.0 AS builder
WORKDIR /workspace

# Copy package manifests first to leverage Docker cache (lockfile expected at repo root)
COPY package.json pnpm-lock.yaml* ./

# Copy the rest of the repository (including monorepo workspaces)
COPY . .

# Install pnpm globally as required by the blueprint
RUN npm install -g pnpm@9

# Install dependencies for the entire monorepo and then build
RUN pnpm install --frozen-lockfile
RUN pnpm -w run build

# Runtime stage: provide a minimal image with the built artifacts
FROM node:20.9.0
WORKDIR /app

# Bring over dependencies and built artifacts from builder
COPY --from=builder /workspace/node_modules /app/node_modules
COPY --from=builder /workspace/packages/open-next/dist /app/packages/open-next/dist
COPY --from=builder /workspace/packages/open-next/package.json /app/packages/open-next/package.json

# Default command: run the built OpenNext AWS CLI
ENTRYPOINT ["node", "/app/packages/open-next/dist/index.js"]
CMD ["build"]