-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (27 loc) · 877 Bytes
/
Dockerfile
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
# Step 1 - compile code binary
FROM golang:1.22.1-alpine AS builder
LABEL maintainer="Charles Guertin <[email protected]>"
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT=""
ARG BUILD_DATE
ARG VERSION
ARG GIT_COMMIT
ENV CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
GOARM=${TARGETVARIANT} \
BUILD_DATE=${BUILD_DATE} \
VERSION=${VERSION} \
GIT_COMMIT=${GIT_COMMIT}
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . ./
RUN go build \
-ldflags "-X github.com/cguertin14/k3supdater/cmd.Version=${VERSION} -X github.com/cguertin14/k3supdater/cmd.BuildDate=${BUILD_DATE} -X github.com/cguertin14/k3supdater/cmd.GitCommit=${GIT_COMMIT}" \
-o ./k3supdater .
# Step 2 - import necessary files to run program.
FROM gcr.io/distroless/base-debian11:nonroot
COPY --from=builder /app/k3supdater /k3supdater
ENTRYPOINT ["/k3supdater"]