File size: 1,001 Bytes
b4d55d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Build stage
FROM golang:1.23-alpine AS builder

# Install build dependencies
RUN apk add --no-cache git

WORKDIR /app

# Copy go.mod and go.sum and download dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy the entire source code
COPY . .

# Build the binary
RUN go build -o main ./cmd/server

# Final stage
FROM debian:stable-slim

# Install CA certificates for HTTPS requests
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 user
USER user
WORKDIR /app

# Copy the binary and necessary runtime files
COPY --from=builder --chown=user /app/main /app/cli-proxy-api-plus
COPY --chown=user config.yaml /app/config.yaml
COPY --chown=user static /app/static
COPY --chown=user auth /app/auth

# Ensure the binary is executable
RUN chmod +x /app/cli-proxy-api-plus

# CLIProxyAPI runs on port 7860 for HF Spaces
EXPOSE 7860

# Start the proxy server
CMD ["./cli-proxy-api-plus", "-config", "config.yaml"]