# syntax=docker/dockerfile:1 # Build from monorepo root: docker build -f apps/edr-freight-api/Dockerfile . FROM node:24.15.0-alpine AS base # Puppeteer ships a glibc Chrome that cannot run on Alpine; skip the ~150MB # download at install time. The runner stage installs Alpine's system Chromium. ENV PUPPETEER_SKIP_DOWNLOAD=true # Chromium + fonts for Puppeteer PDF rendering (contract/invoice/receipt docs). # Without these, Puppeteer fails to launch and the code degrades to an # unformatted plain-text PDF fallback. Use Alpine's system Chromium (musl-built); # the glibc Chrome that `puppeteer install` downloads cannot run on Alpine. RUN apk add --no-cache \ libc6-compat \ chromium \ nss \ freetype \ harfbuzz \ ca-certificates \ ttf-freefont \ font-noto-cjk ENV NODE_ENV=production # Point Puppeteer at the system Chromium and skip its bundled download. ENV PUPPETEER_SKIP_DOWNLOAD=true ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser # Store pnpm's content-addressable store under PNPM_HOME so the BuildKit # `--mount=type=cache,target=/pnpm/store` cache actually persists deps across builds. ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable WORKDIR /app FROM base AS pruner COPY . . RUN pnpm dlx turbo prune "@edr/freight-api" --docker FROM base AS installer COPY --from=pruner /app/out/json/ . COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml RUN --mount=type=secret,id=npmrc,target=./.npmrc,required=false \ --mount=type=cache,id=pnpm,target=/pnpm/store \ pnpm install --frozen-lockfile FROM base AS builder COPY --from=installer /app/ . COPY --from=pruner /app/out/full/ . RUN pnpm turbo build --filter="@edr/freight-api..." FROM base AS deployer COPY --from=builder /app/ . RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ pnpm deploy --filter="@edr/freight-api" --prod --legacy /deploy FROM base AS runner ENV NODE_ENV=production WORKDIR /app RUN addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 --ingroup nodejs nestjs COPY --from=deployer --chown=nestjs:nodejs /deploy . USER nestjs EXPOSE 3001 # GT06 GPS tracker TCP listener (raw TCP, not HTTP). Change via GT06_TCP_PORT. EXPOSE 5023 CMD ["node", "dist/main.js"]