-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (26 loc) · 1.12 KB
/
Dockerfile
File metadata and controls
36 lines (26 loc) · 1.12 KB
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
35
36
FROM golang:1.24.2-alpine AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source code into the container
COPY . .
# Build the Go app
# CGO_ENABLED=0 is important for a static build, which is necessary for a scratch/distroless image
# -o /app/lmt specifies the output file name
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o lmt ./cmd/server/main.go
# ---- Runtime Stage ----
# Use a minimal image for the runtime environment
FROM alpine:latest
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy the built binary from the builder stage to /usr/local/bin
COPY --from=builder /app/lmt /usr/local/bin/lmt
# Copy the example configuration file
# The user will need to mount a real configuration file
COPY lmt.conf.example /app/lmt.conf.example
# Command to run the executable
# The user will likely need to pass arguments or a config file path
ENTRYPOINT ["/usr/local/bin/lmt"]