54 lines
1.5 KiB
Docker
54 lines
1.5 KiB
Docker
# Start from the pre-built Nextjs Base image
|
|
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Build-time environment variables for Next.js
|
|
ARG NEXT_PUBLIC_BASE_URL
|
|
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
|
ARG NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
|
ARG NEXT_PUBLIC_TARGET
|
|
ARG DIRECTUS_URL
|
|
|
|
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
|
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
|
ENV NEXT_PUBLIC_UMAMI_SCRIPT_URL=$NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
|
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
|
ENV DIRECTUS_URL=$DIRECTUS_URL
|
|
|
|
# Build the specific application
|
|
RUN pnpm --filter sample-website build
|
|
|
|
# Production runner image
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apk add --no-cache curl
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/apps/sample-website/public ./apps/sample-website/public
|
|
|
|
# Set the correct permission for prerender cache
|
|
RUN mkdir -p apps/sample-website/.next
|
|
RUN chown nextjs:nodejs apps/sample-website/.next
|
|
|
|
# Copy standalone output and static files from the monorepo path
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/static ./apps/sample-website/.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# server.js in monorepo standalone is created for each app
|
|
CMD ["node", "apps/sample-website/server.js"]
|