Declare and pass PocketBase, TomTom, and QuickBooks webhook public variables into the Docker build environment so Next.js can bake Ship-provided values into the browser bundle.
44 lines
1.4 KiB
Docker
44 lines
1.4 KiB
Docker
FROM node:20-alpine AS base
|
|
|
|
FROM node:20-alpine AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
# Public variables are baked into the browser code by `next build`, so they must
|
|
# exist at build time. Ship passes them from .env.local; a name that is not
|
|
# declared here is silently ignored by the build.
|
|
ARG NEXT_PUBLIC_POCKETBASE_URL
|
|
ARG NEXT_PUBLIC_TOMTOM_API_KEY
|
|
ARG NEXT_PUBLIC_QB_INVOICE_WEBHOOK_URL
|
|
ENV NEXT_PUBLIC_POCKETBASE_URL=${NEXT_PUBLIC_POCKETBASE_URL}
|
|
ENV NEXT_PUBLIC_TOMTOM_API_KEY=${NEXT_PUBLIC_TOMTOM_API_KEY}
|
|
ENV NEXT_PUBLIC_QB_INVOICE_WEBHOOK_URL=${NEXT_PUBLIC_QB_INVOICE_WEBHOOK_URL}
|
|
# The commit being built, supplied by Ship. Declared late so the layers above
|
|
# stay cached; it is empty for builds that do not pass it.
|
|
ARG NEXT_PUBLIC_APP_COMMIT
|
|
ENV NEXT_PUBLIC_APP_COMMIT=${NEXT_PUBLIC_APP_COMMIT}
|
|
RUN npm run build
|
|
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
CMD ["node", "server.js"]
|