-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (25 loc) · 833 Bytes
/
Dockerfile
File metadata and controls
34 lines (25 loc) · 833 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
31
32
33
34
# Build Stage
FROM golang:1.23.4 AS builder
ENV CGO_ENABLED=0 \
GOOS=linux
WORKDIR /app
# Download Go modules
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/reference/dockerfile/#copy
COPY . ./
# Disable CGO and set target OS to Linux for a portable static binary
RUN go build -o /techbloghub-server ./cmd/main.go
# Final Stage
FROM alpine:latest AS deployment
# copy only built binaries
COPY --from=builder /techbloghub-server ./
# Optional:
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
# But we can document in the Dockerfile what ports
# the application is going to listen on by default.
# https://docs.docker.com/reference/dockerfile/#expose
EXPOSE 8080
# Run
CMD ["./techbloghub-server"]