- 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
69 lines
1.6 KiB
Docker
69 lines
1.6 KiB
Docker
# Build stage
|
|
FROM golang:1.21-alpine AS go-builder
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache gcc musl-dev
|
|
|
|
# Build stage for Node
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Install build dependencies including Go
|
|
RUN apk add --no-cache python3 make g++ git go
|
|
|
|
# Set up working directory
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
COPY pnpm-lock.yaml* ./
|
|
COPY .npmrc* ./
|
|
COPY nx.json ./
|
|
COPY tsconfig*.json ./
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN pnpm nx run-many --target=build --all --parallel
|
|
|
|
# Production stage
|
|
FROM node:20-alpine AS production
|
|
|
|
# Install runtime dependencies
|
|
RUN apk add --no-cache tini docker-cli curl
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nodejs -u 1001
|
|
|
|
# Set up working directory
|
|
WORKDIR /app
|
|
|
|
# Copy built application from builder
|
|
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
|
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./
|
|
COPY --from=builder --chown=nodejs:nodejs /app/nx.json ./
|
|
COPY --from=builder --chown=nodejs:nodejs /app/tsconfig*.json ./
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/data /app/sandboxes /app/logs && \
|
|
chown -R nodejs:nodejs /app
|
|
|
|
# Switch to non-root user
|
|
USER nodejs
|
|
|
|
# Expose port
|
|
EXPOSE 8002
|
|
|
|
# Use tini for proper signal handling
|
|
ENTRYPOINT ["/sbin/tini", "--"]
|
|
|
|
# Start the application
|
|
CMD ["node", "dist/apps/api/main.js"] |