2024-06-21 21:38:01 +00:00
|
|
|
# Build stage
|
|
|
|
FROM golang:1.21.4-alpine AS builder
|
2023-11-22 15:45:57 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY go.mod ./
|
|
|
|
|
|
|
|
# download Go modules and dependencies
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
# copy all the Go files ending with .go extension
|
|
|
|
COPY *.go ./
|
|
|
|
|
2024-06-21 21:38:01 +00:00
|
|
|
RUN go build -o golang-http-header
|
|
|
|
|
|
|
|
# Final stage
|
|
|
|
FROM scratch
|
|
|
|
|
|
|
|
COPY --from=builder /app/golang-http-header /
|
2023-11-22 15:45:57 +00:00
|
|
|
|
|
|
|
# network port at runtime
|
|
|
|
EXPOSE 8000
|
|
|
|
|
2024-06-21 21:38:01 +00:00
|
|
|
CMD ["/golang-http-header"]
|