tenantpilot/worker/Dockerfile
Ahmed Darrazi 024c5fca00
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 1s
fix: Adjust Dockerfile COPY paths for worker/ build context
2025-12-09 13:48:51 +01:00

33 lines
1.3 KiB
Docker

### Multi-stage build: compile TypeScript in a builder image, produce a smaller runtime image
### IMPORTANT: Dokploy will set build context to worker/ directory automatically
### All COPY paths must be relative to worker/ (use ../ to access parent repo root)
FROM node:20 AS builder
WORKDIR /usr/src/app
# Copy package manifests from parent directory and install all deps (including dev) for build
COPY ../package.json ../package-lock.json ./
RUN npm ci --silent
# Copy entire project from parent directory and compile TypeScript
COPY ../ .
# Try to compile the project; if there is no TS config for worker, keep files as-is
RUN npx tsc -p tsconfig.json --outDir dist || echo "tsc exit code ignored"
FROM node:20-alpine AS runner
WORKDIR /usr/src/app
# Install only production dependencies
COPY ../package.json ../package-lock.json ./
RUN npm ci --production --silent
# Copy compiled output from builder (if present) and essential runtime files
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/worker ./worker
COPY --from=builder /usr/src/app/lib ./lib
ENV NODE_ENV=production
# If compiled JS exists, run compiled entrypoint; otherwise fallback to tsx runtime
CMD ["sh", "-c", "if [ -f ./dist/worker/index.js ]; then node ./dist/worker/index.js; else npx tsx ./worker/index.ts; fi"]