Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -9
Dockerfile
CHANGED
|
@@ -1,26 +1,29 @@
|
|
| 1 |
-
#
|
| 2 |
FROM golang:1.22-alpine AS builder
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
-
#
|
| 9 |
RUN git clone https://github.com .
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
RUN go build -o cliproxy ./cmd/main.go
|
| 13 |
|
| 14 |
-
#
|
| 15 |
FROM alpine:latest
|
|
|
|
|
|
|
| 16 |
WORKDIR /app
|
| 17 |
|
| 18 |
-
#
|
| 19 |
COPY --from=builder /app/cliproxy .
|
| 20 |
COPY --from=builder /app/config.example.yaml ./config.yaml
|
| 21 |
|
| 22 |
-
#
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
-
#
|
| 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"]
|