Add Docker support with comprehensive deployment options
- Add multi-stage Dockerfile with optimized builds for Go backend and Node.js frontend - Create docker-entrypoint.sh script for managing both services with PM2 - Add .dockerignore for optimal build context - Update README.md with Docker deployment documentation including: - Docker build and run instructions - Persistent data configuration with volume mounts - Complete environment variable reference table - Docker Compose example configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9cb513019d
commit
602452b162
4 changed files with 375 additions and 3 deletions
85
Dockerfile
Normal file
85
Dockerfile
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# Multi-stage Dockerfile for Claude Code Proxy
|
||||
# Builds both Go proxy server and Remix frontend in a single container
|
||||
|
||||
# Stage 1: Build Go Backend
|
||||
FROM golang:1.21-alpine AS go-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Copy Go modules
|
||||
COPY proxy/go.mod proxy/go.sum ./proxy/
|
||||
WORKDIR /app/proxy
|
||||
RUN go mod download
|
||||
|
||||
# Copy Go source code
|
||||
COPY proxy/ ./
|
||||
RUN go build -o /app/bin/proxy cmd/proxy/main.go
|
||||
|
||||
# Stage 2: Build Node.js Frontend
|
||||
FROM node:20-alpine AS node-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY web/package*.json ./web/
|
||||
WORKDIR /app/web
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy web source code and build
|
||||
COPY web/ ./
|
||||
RUN npm run build
|
||||
|
||||
# Stage 3: Production Runtime
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install process manager for running multiple services
|
||||
RUN npm install -g pm2
|
||||
|
||||
# Create app user for security
|
||||
RUN addgroup -g 1001 -S appgroup && \
|
||||
adduser -S appuser -u 1001 -G appgroup
|
||||
|
||||
# Copy built Go binary
|
||||
COPY --from=go-builder /app/bin/proxy ./bin/proxy
|
||||
RUN chmod +x ./bin/proxy
|
||||
|
||||
# Copy built Remix application
|
||||
COPY --from=node-builder /app/web/build ./web/build
|
||||
COPY --from=node-builder /app/web/package*.json ./web/
|
||||
COPY --from=node-builder /app/web/node_modules ./web/node_modules
|
||||
|
||||
# Create data directory for SQLite database
|
||||
RUN mkdir -p /app/data && chown -R appuser:appgroup /app
|
||||
|
||||
# Copy startup script
|
||||
COPY docker-entrypoint.sh ./
|
||||
RUN chmod +x docker-entrypoint.sh
|
||||
|
||||
# Environment variables with defaults
|
||||
ENV PORT=3001
|
||||
ENV WEB_PORT=5173
|
||||
ENV READ_TIMEOUT=600
|
||||
ENV WRITE_TIMEOUT=600
|
||||
ENV IDLE_TIMEOUT=600
|
||||
ENV ANTHROPIC_FORWARD_URL=https://api.anthropic.com
|
||||
ENV ANTHROPIC_VERSION=2023-06-01
|
||||
ENV ANTHROPIC_MAX_RETRIES=3
|
||||
ENV DB_PATH=/app/data/requests.db
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 3001 5173
|
||||
|
||||
# Switch to app user
|
||||
USER appuser
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT}/health || exit 1
|
||||
|
||||
# Start both services
|
||||
CMD ["./docker-entrypoint.sh"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue