-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.local
More file actions
48 lines (38 loc) · 1.26 KB
/
Dockerfile.local
File metadata and controls
48 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Multi-stage build for Claude Code CLI with OpenAI API
# 本地构建版本 - 适用于当前平台
# Frontend build stage
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build
# Backend build stage
FROM golang:1.24-alpine AS backend-builder
RUN apk add --no-cache gcc musl-dev sqlite-dev
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=frontend-builder /app/frontend/build ./frontend/build
RUN CGO_ENABLED=1 go build -ldflags="-w -s" -o claude-with-openai-api .
# Final stage - minimal Alpine image
FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata && \
addgroup -g 1000 app && \
adduser -D -u 1000 -G app app
WORKDIR /app
# Copy binary from builder
COPY --from=backend-builder /app/claude-with-openai-api .
# Create data directory with proper permissions
RUN mkdir -p /app/data && \
chown -R app:app /app
# Switch to non-root user
USER app
# Expose port
EXPOSE 54988
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:54988/health || exit 1
# Use exec form to ensure proper signal handling
CMD ["./claude-with-openai-api", "server"]