Files
GoClaw/docker/Dockerfile.control-center
¨NW¨ 322cebf475 fix(prod): production startup fixes — health endpoint, serveStatic path, entrypoint, docker config
- Add /api/health endpoint for Docker healthchecks
- Fix serveStatic path: dist/public instead of ../public
- Fix entrypoint.sh: DB wait check, npx drizzle-kit migrate, add netcat
- Fix Dockerfile: add bash/netcat, fix COPY order, add tsconfig.node.json
- Fix docker-compose.yml: add OLLAMA/LLM env vars for Node.js fallback
- Fix docker-stack.yml: remove template vars, use env vars instead of secrets
- Fix drizzle.config.ts: add migrations prefix
- Update .env.example with full LLM provider documentation
2026-04-08 23:09:28 +01:00

71 lines
2.0 KiB
Docker

# ── Build Stage ──────────────────────────────────────────────────────────────
FROM node:22-alpine AS builder
# Install pnpm
RUN npm install -g pnpm@latest
WORKDIR /app
# Copy package files and patches for layer caching
COPY package.json pnpm-lock.yaml ./
COPY patches/ ./patches/
RUN pnpm install --frozen-lockfile
# Copy all source code needed for build
COPY client/ ./client/
COPY server/ ./server/
COPY shared/ ./shared/
COPY drizzle/ ./drizzle/
COPY drizzle.config.ts tsconfig.json tsconfig.node.json vite.config.ts vitest.config.ts ./
# Build frontend (Vite) and backend (esbuild)
RUN pnpm build
# ── Runtime Stage ─────────────────────────────────────────────────────────────
FROM node:22-alpine
# Install runtime dependencies
RUN apk add --no-cache \
wget \
curl \
bash \
netcat-openbsd \
&& rm -rf /var/cache/apk/*
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm@latest
# Copy package files and install production deps only
COPY package.json pnpm-lock.yaml ./
COPY patches/ ./patches/
# Install all deps (drizzle-kit needed for migrations at runtime)
RUN pnpm install --frozen-lockfile --ignore-scripts
# Copy built artifacts from builder
COPY --from=builder /app/dist ./dist
# Copy drizzle config and migrations for runtime migration
COPY drizzle.config.ts ./drizzle.config.ts
COPY drizzle/ ./drizzle/
# Copy entrypoint script
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Run as non-root user
RUN addgroup -g 1001 goclaw && \
adduser -u 1001 -G goclaw -s /bin/sh -D goclaw && \
chown -R goclaw:goclaw /app
USER goclaw
EXPOSE 3000
# Health check
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=3 \
CMD wget -qO- http://localhost:3000/api/health || exit 1
ENTRYPOINT ["/entrypoint.sh"]