Remodel/packages/web/Dockerfile
Manohar Gupta ef3f2ace25
Some checks are pending
CI / Engine — lint / typecheck / test (push) Waiting to run
CI / API — lint / typecheck / test (push) Waiting to run
CI / Web — typecheck / lint / build (push) Waiting to run
fix: pass NEXT_PUBLIC_API_URL as Docker build ARG so Next.js bakes it into bundle
2026-05-15 05:15:25 +00:00

45 lines
1 KiB
Docker

FROM node:22-alpine AS builder
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy web package
COPY package.json pnpm-lock.yaml ./
COPY . .
# Create placeholder .env.local if not exists (needed for prod build)
RUN test -f .env.local || echo "# placeholder" > .env.local
# Install dependencies
RUN pnpm install --frozen-lockfile --ignore-scripts
# Inject NEXT_PUBLIC_API_URL at build time (Next.js bakes NEXT_PUBLIC_* into the bundle)
ARG NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
# Build
RUN pnpm build
# Production runner
FROM node:22-alpine
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy built artifacts
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json .
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.env.local ./.env.local
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
EXPOSE 3000
CMD ["/app/node_modules/.bin/next", "start"]