/ go-proxy-cache / Dockerfile
Dockerfile
1 # Build stage 2 FROM golang:1.24-alpine AS builder 3 4 # Install dependencies 5 RUN apk add --no-cache git 6 7 # Set working directory 8 WORKDIR /app 9 10 # Copy proxy-common first (dependency for replace directive) 11 COPY proxy-common /proxy-common 12 13 # Copy go mod files 14 COPY go-proxy-cache/go.mod go-proxy-cache/go.sum ./ 15 16 # Download dependencies 17 RUN go mod download 18 19 # Copy source code 20 COPY go-proxy-cache/ . 21 22 # Build the application 23 RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o rpc-cache ./cmd/rpc-cache 24 25 # Final stage 26 FROM alpine:latest 27 28 # Install ca-certificates for HTTPS requests 29 RUN apk --no-cache add ca-certificates 30 31 # Create app directory 32 WORKDIR /root/ 33 34 # Copy the binary from builder stage 35 COPY --from=builder /app/rpc-cache . 36 37 # Create config directory 38 RUN mkdir -p /app 39 40 # Copy config files 41 COPY go-proxy-cache/cache_config.yaml go-proxy-cache/cache_rules.yaml /app/ 42 43 # Expose port 44 EXPOSE 8080 45 46 # Environment variables with defaults 47 ENV CACHE_CONFIG_FILE=/app/cache_config.yaml 48 ENV CACHE_RULES_FILE=/app/cache_rules.yaml 49 ENV CACHE_SERVER_ADDR=:8080 50 51 # Run the binary 52 CMD ["./rpc-cache"] 53