API Dockerfile Troubleshooting
| Created | Updated | Status | Type |
|---|---|---|---|
| 2026-02-01 | 2026-02-01 | ✅ Done | Guide |
Overview
Documents common API Dockerfile issues encountered during CI/CD deployment and their solutions.
Issues & Solutions
1. PNPM Workspace Package Not Found
Error:
ERR_PNPM_WORKSPACE_PKG_NOT_FOUND: "@repo/config@workspace:*" is in the dependencies
but no package named "@repo/config" is present in the workspace
Cause: Runner stage copies original package.json which references workspace packages (@repo/config, @repo/utils). In isolated runner stage, monorepo structure doesn't exist.
Solution: Create minimal package.json inline instead of copying original:
# BAD - copies workspace dependencies
COPY --from=builder /app/apps/api/package.json ./package.json
RUN pnpm add drizzle-kit postgres --prod
# GOOD - create clean package.json
RUN echo '{"name":"api"}' > package.json && \
pnpm add drizzle-kit drizzle-orm postgres tsx
2. Container Unhealthy - wget Not Found
Error:
Container flowershop-api is unhealthy
dependency failed to start: container flowershop-api is unhealthy
Cause: Healthcheck uses wget but Alpine doesn't include it by default:
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3001/api/health"]
Solution: Install wget in runner stage:
FROM node:22-alpine AS runner
RUN apk add --no-cache wget