opennextjs-opennextjs-aws
SUCCESS
7m 39s
History Source
SummaryIterations1Transcript12Dockerfile
Dockerfile32 lines · 985 chars
# Builder stage: install dependencies and build the AWS package from source
FROM node:20-slim AS builder

WORKDIR /workspace

# Copy the entire repository first to leverage build cache
COPY . .

# Use corepack/pnpm to manage dependencies
RUN corepack enable

# Install dependencies for the monorepo
RUN pnpm install

# Build the OpenNext AWS package from source
RUN pnpm --filter @opennextjs/aws run build

# Runtime stage: ship the built package and dependencies
FROM node:20-slim

WORKDIR /workspace

# Copy built artifacts and dependencies from builder
COPY --from=builder /workspace/packages/open-next/dist ./packages/open-next/dist
COPY --from=builder /workspace/node_modules ./node_modules

# Copy the AWS package.json for reference (optional runtime tooling)
COPY --from=builder /workspace/packages/open-next/package.json ./packages/open-next/package.json

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