File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1+ # ---- Build stage ----
2+ FROM golang:1.24-alpine AS builder
3+
4+ # Install CA certificates (needed for HTTPS requests)
5+ RUN apk add --no-cache ca-certificates
6+
7+ WORKDIR /app
8+
9+ COPY go.mod .
10+ RUN go mod download
11+
12+ COPY main.go .
13+
14+ # Build static binary
15+ RUN CGO_ENABLED=0 GOOS=linux go build -o proxy .
16+
17+ # ---- Runtime stage ----
18+ FROM scratch
19+
20+ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
21+ COPY --from=builder /app/proxy /proxy
22+
23+ # Run proxy
24+ ENTRYPOINT ["/proxy" ]
Original file line number Diff line number Diff line change 1+ module myproxy
2+
3+ go 1.24
Original file line number Diff line number Diff line change @@ -140,8 +140,13 @@ func callAndLogError(f func() error) {
140140}
141141
142142func main () {
143+ port := os .Getenv ("PORT" )
144+ if port == "" {
145+ port = "8080"
146+ }
147+
143148 server := & http.Server {
144- Addr : ":8080" , // listen on port 8080
149+ Addr : ":" + port , // listen on port 8080
145150 Handler : http .HandlerFunc (HandleProxy ),
146151 }
147152
You can’t perform that action at this time.
0 commit comments