Skip to content

Commit b9f8d7c

Browse files
authored
Update Dockerfile
1 parent 0ab62d0 commit b9f8d7c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Stage 1: Build the Go application
12
FROM golang:1.22.5-alpine AS builder
23
# Install required system packages
34
RUN apk update && \
@@ -17,16 +18,20 @@ RUN go mod download
1718
# Build the application
1819
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o proxy-server .
1920

20-
# Intermediate stage to include nc
21+
# Stage 2: Build the nc binary
2122
FROM alpine:latest AS nc-builder
2223
RUN apk add --no-cache netcat-openbsd
2324

24-
# Final stage
25+
# Stage 3: Final scratch image
2526
FROM scratch
2627
WORKDIR /app
28+
29+
# Copy the Go binary and CA certificates
2730
COPY --from=builder /build/proxy-server .
2831
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
29-
COPY --from=nc-builder /bin/nc /bin/nc
32+
33+
# Copy the nc binary from the nc-builder stage
34+
COPY --from=nc-builder /usr/bin/nc /bin/nc
3035

3136
EXPOSE 1080
32-
CMD ["./proxy-server"]
37+
CMD ["./proxy-server"]

0 commit comments

Comments
 (0)