Coolify auto-injects ARG NODE_ENV into all Dockerfile stages and passes NODE_ENV=production as a build arg. This causes npm ci to skip devDependencies (including typescript), making tsc not found (exit 127) at npm run build. Fix: prefix the npm ci call with NODE_ENV=development to override the injected env var only for the install step, ensuring TypeScript and other build tools are always installed. Co-Authored-By: Paperclip <noreply@paperclip.ing>
63 lines
2.8 KiB
Docker
63 lines
2.8 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Stage 1: Dependencies (production only)
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
FROM node:22-bookworm-slim AS deps
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --omit=dev --prefer-offline
|
|
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Stage 2: Build
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
FROM node:22-bookworm-slim AS build
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Force devDependencies: NODE_ENV=production (injected by Coolify as build arg)
|
|
# would cause npm to skip devDeps, so we explicitly override here.
|
|
RUN NODE_ENV=development npm ci
|
|
|
|
COPY tsconfig.json tsconfig.build.json ./
|
|
COPY src ./src
|
|
|
|
RUN npm run build
|
|
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# Stage 3: Runtime
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
FROM node:22-bookworm-slim AS runtime
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
tini \
|
|
ca-certificates \
|
|
curl && \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
useradd --system --uid 1001 --create-home agenthub
|
|
|
|
COPY --from=deps --chown=agenthub:agenthub /app/node_modules ./node_modules
|
|
COPY --from=build --chown=agenthub:agenthub /app/dist ./dist
|
|
COPY --chown=agenthub:agenthub package.json ./
|
|
COPY --chown=agenthub:agenthub drizzle ./drizzle
|
|
COPY --chown=agenthub:agenthub drizzle.config.ts ./
|
|
COPY --chown=agenthub:agenthub scripts ./scripts
|
|
|
|
USER agenthub
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
|
CMD curl -f http://127.0.0.1:3000/healthz || exit 1
|
|
|
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
|
CMD ["node", "dist/server.js"]
|