Files
runtime/Dockerfile
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

83 lines
1.6 KiB
Docker

# Hanzo Runtime Service Dockerfile
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY pnpm-lock.yaml* ./
COPY .npmrc* ./
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm build || npm run build || true
# Development stage
FROM node:20-alpine AS development
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy package files
COPY package*.json ./
COPY pnpm-lock.yaml* ./
COPY .npmrc* ./
# Install all dependencies (including dev)
RUN pnpm install
# Copy source code
COPY . .
# Expose port
EXPOSE 3000
# Development command with hot reload
CMD ["pnpm", "dev"]
# Production stage
FROM node:20-alpine AS production
WORKDIR /app
# Install runtime dependencies only
RUN apk add --no-cache tini
# Copy built application from builder
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/pnpm-lock.yaml* ./
COPY --from=builder /app/.npmrc* ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public 2>/dev/null || true
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
# Switch to non-root user
USER nodejs
# Expose port
EXPOSE 3000
# Use tini for proper signal handling
ENTRYPOINT ["/sbin/tini", "--"]
# Production command
CMD ["node", "dist/index.js"]
# Default to production stage
FROM production