Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Commit cf49bb6

Browse files
committed
Refactor Dockerfile to use multi-stage builds for optimized image size and add HTTPS certificates
1 parent 766e74b commit cf49bb6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Dockerfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
FROM golang:latest
1+
# Build stage
2+
FROM golang:latest AS builder
23

34
WORKDIR /app
45

56
COPY . .
67

78
RUN go mod download
8-
RUN go build -o /bridge_server
9+
RUN CGO_ENABLED=0 GOOS=linux go build -o /bridge_server
910

10-
CMD [ "/bridge_server" ]
11+
# Final stage
12+
FROM alpine:latest
13+
14+
WORKDIR /app
15+
16+
# Copy only the binary from the builder stage
17+
COPY --from=builder /bridge_server /app/bridge_server
18+
19+
# Add necessary certificates for HTTPS
20+
RUN apk --no-cache add ca-certificates
21+
22+
CMD [ "/app/bridge_server" ]

0 commit comments

Comments
 (0)