-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (25 loc) · 783 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (25 loc) · 783 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
# First stage of multi-stage build: build the Go binary
FROM golang:1.19-alpine AS builder
# Create directory for build context
WORKDIR /build
# Get the required files
COPY go.mod .
COPY go.sum .
COPY *.go ./
COPY VERSION .
# Download all dependencies
RUN go mod download
# Build the Go app
RUN CGO_ENABLED=0 go build -ldflags="-X main.AppVersion=$(cat VERSION) -s -w" -trimpath -o sessionprobe .
# Second stage of multi-stage build: run the Go binary
FROM alpine:latest
# Create required directories and adjust working directory
RUN mkdir /app /app/files
WORKDIR /app/files
# Running as a non-root user
RUN adduser -D local
USER local
# Copy binary from first stage
COPY --from=builder /build/sessionprobe /app
# This command runs the app
ENTRYPOINT ["/app/sessionprobe"]