45 lines
2.3 KiB
Text
45 lines
2.3 KiB
Text
# ─── Pipeline worker Dockerfile ───────────────────────────────────────────────
|
|
# Debian slim — needed for osmium-tool and osm2pgsql (not in Alpine).
|
|
# Also serves as the routing queue consumer using @valhallajs/valhallajs
|
|
# (glibc prebuilt binary; no separate valhalla HTTP server needed).
|
|
|
|
FROM node:22-slim AS build
|
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /app
|
|
|
|
# ─── Dependencies (glibc — required for @valhallajs/valhallajs native addon) ──
|
|
COPY package.json package-lock.json* tsconfig.base.json ./
|
|
COPY apps/web/package.json ./apps/web/
|
|
COPY worker/package.json ./worker/
|
|
COPY shared/package.json ./shared/
|
|
# NODE_ENV must NOT be production here — devDependencies (tsc, tsx, etc.) needed
|
|
RUN npm install --workspace=apps/web --workspace=worker --workspace=shared
|
|
|
|
# ─── Shared + worker build ────────────────────────────────────────────────────
|
|
COPY shared/ ./shared/
|
|
RUN npm run build --workspace=shared
|
|
COPY worker/ ./worker/
|
|
RUN npm run build --workspace=worker
|
|
|
|
# ─── Runtime ──────────────────────────────────────────────────────────────────
|
|
FROM node:22-slim AS worker
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
osmium-tool \
|
|
osm2pgsql \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN groupadd --system --gid 1001 nodejs && useradd --system --uid 1001 --gid nodejs workeruser
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
COPY --from=build /app/node_modules ./node_modules
|
|
COPY --from=build /app/worker/dist ./worker/dist
|
|
COPY --from=build /app/shared/dist ./shared/dist
|
|
COPY shared/package.json ./shared/
|
|
COPY infra/ ./infra/
|
|
COPY worker/package.json ./worker/
|
|
# Create data directories owned by workeruser so Docker named volumes
|
|
# are initialized with the correct permissions on first run.
|
|
RUN mkdir -p /data/osm /data/valhalla /data/valhalla_road /data/valhalla_transit \
|
|
&& chown -R workeruser:nodejs /data
|
|
USER workeruser
|
|
CMD ["node", "worker/dist/index.js"]
|