Bottomg32311 commited on
Commit
00845f8
·
verified ·
1 Parent(s): 48ae3a5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -9
Dockerfile CHANGED
@@ -1,26 +1,29 @@
1
- # Stage 1: Build the binary straight from GitHub source
2
  FROM golang:1.22-alpine AS builder
3
 
4
- RUN apk add --no-cache git
 
5
 
6
  WORKDIR /app
7
 
8
- # Automatically clone the exact source code repository
9
  RUN git clone https://github.com .
10
 
11
- # Compile the application
12
- RUN go build -o cliproxy ./cmd/main.go
13
 
14
- # Stage 2: Create a minimal deployment image
15
  FROM alpine:latest
 
 
16
  WORKDIR /app
17
 
18
- # Pull the compiled binary and example config from stage 1
19
  COPY --from=builder /app/cliproxy .
20
  COPY --from=builder /app/config.example.yaml ./config.yaml
21
 
22
- # Hugging Face Spaces strictly run on port 7860
23
  EXPOSE 7860
24
 
25
- # Execute the application on the required port
26
  CMD ["./cliproxy", "--port", "7860"]
 
1
+ # Step 1: Use an official Go alpine build environment
2
  FROM golang:1.22-alpine AS builder
3
 
4
+ # Install secure networking tools
5
+ RUN apk add --no-cache git ca-certificates
6
 
7
  WORKDIR /app
8
 
9
+ # Clone the exact repository target into the app directory
10
  RUN git clone https://github.com .
11
 
12
+ # Fetch dependencies and compile the runtime binary safely
13
+ RUN go mod download && CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o cliproxy ./cmd/main.go
14
 
15
+ # Step 2: Use a clean runtime environment
16
  FROM alpine:latest
17
+ RUN apk add --no-cache ca-certificates
18
+
19
  WORKDIR /app
20
 
21
+ # Copy compiled executable and the baseline layout blueprint from builder stage
22
  COPY --from=builder /app/cliproxy .
23
  COPY --from=builder /app/config.example.yaml ./config.yaml
24
 
25
+ # Open the network listener gate required by Hugging Face Spaces
26
  EXPOSE 7860
27
 
28
+ # Run the proxy, binding it explicitly to Hugging Face's assigned port layout
29
  CMD ["./cliproxy", "--port", "7860"]