# Build stage FROM golang:1.23-alpine AS builder ENV GOTOOLCHAIN=auto WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . ARG VERSION=dev ARG COMMIT=none ARG BUILD_DATE=unknown RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.Commit=${COMMIT}' -X 'main.BuildDate=${BUILD_DATE}'" -o ./CLIProxyAPI ./cmd/server/ FROM alpine:3.20 RUN apk add --no-cache tzdata ca-certificates RUN mkdir -p /CLIProxyAPI/auth-credentials /data/auth-credentials COPY --from=builder ./app/CLIProxyAPI /CLIProxyAPI/CLIProxyAPI # Create production config inline (no local file dependency) RUN echo 'host: "0.0.0.0"' > /CLIProxyAPI/config.yaml && \ echo 'port: 8317' >> /CLIProxyAPI/config.yaml && \ echo 'tls:' >> /CLIProxyAPI/config.yaml && \ echo ' enable: false' >> /CLIProxyAPI/config.yaml && \ echo 'remote-management:' >> /CLIProxyAPI/config.yaml && \ echo ' allow-remote: false' >> /CLIProxyAPI/config.yaml && \ echo ' disable-control-panel: true' >> /CLIProxyAPI/config.yaml && \ echo 'auth-dir: "/data/auth-credentials"' >> /CLIProxyAPI/config.yaml && \ echo 'api-keys:' >> /CLIProxyAPI/config.yaml && \ echo ' - "sk-cItvhSBsi7KWnTDZqfFX5gzuVURodOL8pPj1CbyJreAk3HYG"' >> /CLIProxyAPI/config.yaml && \ echo 'debug: false' >> /CLIProxyAPI/config.yaml && \ echo 'commercial-mode: true' >> /CLIProxyAPI/config.yaml && \ echo 'logging-to-file: false' >> /CLIProxyAPI/config.yaml && \ echo 'usage-statistics-enabled: true' >> /CLIProxyAPI/config.yaml && \ echo 'request-retry: 3' >> /CLIProxyAPI/config.yaml && \ echo 'max-retry-interval: 30' >> /CLIProxyAPI/config.yaml && \ echo 'quota-exceeded:' >> /CLIProxyAPI/config.yaml && \ echo ' switch-project: true' >> /CLIProxyAPI/config.yaml && \ echo ' switch-preview-model: true' >> /CLIProxyAPI/config.yaml && \ echo 'routing:' >> /CLIProxyAPI/config.yaml && \ echo ' strategy: "round-robin"' >> /CLIProxyAPI/config.yaml && \ echo 'ws-auth: false' >> /CLIProxyAPI/config.yaml && \ echo 'openai-compatibility:' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "pollinations"' >> /CLIProxyAPI/config.yaml && \ echo ' base-url: "https://gen.pollinations.ai/v1"' >> /CLIProxyAPI/config.yaml && \ echo ' api-key-entries:' >> /CLIProxyAPI/config.yaml && \ echo ' - api-key: "sk_lKZK8QOvQkoBBP7pbCZlY6WF2mnnaCnx"' >> /CLIProxyAPI/config.yaml && \ echo ' models:' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "openai"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "openai-fast"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "openai-large"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "qwen-coder"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "mistral"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "openai-audio"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "gemini-fast"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "deepseek"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "gemini-search"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "claude-fast"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "perplexity-fast"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "perplexity-reasoning"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "kimi"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "nova-fast"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "glm"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "minimax"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "qwen-character"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "gemini"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "grok"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "claude"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "claude-large"' >> /CLIProxyAPI/config.yaml && \ echo ' - name: "gemini-large"' >> /CLIProxyAPI/config.yaml WORKDIR /CLIProxyAPI EXPOSE 8317 ENV TZ=UTC CMD ["./CLIProxyAPI"]