49 lines
1.6 KiB
Docker
49 lines
1.6 KiB
Docker
# ---------------------------------------------------------------------------
|
|
# @sport/storefront production image (Next.js standalone output).
|
|
# ---------------------------------------------------------------------------
|
|
FROM node:22-alpine AS base
|
|
RUN corepack enable
|
|
WORKDIR /app
|
|
|
|
FROM base AS pruner
|
|
RUN apk add --no-cache libc6-compat
|
|
COPY . .
|
|
RUN pnpm dlx turbo@2.10.9 prune @sport/storefront --docker
|
|
|
|
FROM base AS builder
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
COPY --from=pruner /app/out/json/ .
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY --from=pruner /app/out/full/ .
|
|
|
|
# NEXT_PUBLIC_* values are inlined into the client bundle at build time, so they
|
|
# must be present here — they cannot be injected at container start.
|
|
ARG NEXT_PUBLIC_API_URL
|
|
ARG NEXT_PUBLIC_SITE_URL
|
|
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
|
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN pnpm turbo run build --filter=@sport/storefront
|
|
|
|
FROM base AS runner
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup -g 1001 -S nodejs && adduser -u 1001 -S nextjs -G nodejs
|
|
|
|
# `output: 'standalone'` emits a self-contained server with only the modules it
|
|
# actually imports — a fraction of the size of copying node_modules.
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/storefront/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/storefront/.next/static ./apps/storefront/.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/storefront/public ./apps/storefront/public
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "apps/storefront/server.js"]
|