mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
50 lines
1.6 KiB
Docker
50 lines
1.6 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# Build from monorepo root: docker build -f apps/edr-freight-api/Dockerfile .
|
|
#
|
|
# The base image (Node + Alpine Chromium/Puppeteer + pnpm) is built and pushed
|
|
# separately — see Dockerfile.base. Override the pinned tag at build time with
|
|
# --build-arg BASE_IMAGE=registry.license.aafda.gov.et/edr-public/freight-api-base:<tag>
|
|
ARG BASE_IMAGE=registry.license.aafda.gov.et/edr-public/freight-api-base:node24-alpine
|
|
|
|
FROM ${BASE_IMAGE} AS base
|
|
|
|
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 deployer AS migration
|
|
WORKDIR /deploy
|
|
CMD ["node", "dist/scripts/migrate.js"]
|
|
|
|
FROM base AS runner
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
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"]
|
|
|