-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.http
More file actions
30 lines (22 loc) · 824 Bytes
/
Dockerfile.http
File metadata and controls
30 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Use the official Golang image to create a build artifact.
FROM golang:1.21-alpine as builder
# Copy local code to the container image.
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . ./
# Change to the directory containing main.go
WORKDIR /app/cmd/server
# Build the command inside the container.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o http_server
# Use a minimal image to run the service
FROM golang:1.21-alpine
WORKDIR /app
# Add CA certificates
RUN apk add --no-cache ca-certificates
# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/cmd/server/http_server /app/http_server
# Copy the .env file to the same directory as the executable
COPY --from=builder /app/.env /app/.env
# Run the service on container startup.
ENTRYPOINT ["/app/http_server"]