-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
51 lines (39 loc) · 1.28 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Build the manager binary
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
ARG GOARCH=''
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
COPY hack hack
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
go mod download
# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY client/ client/
COPY controllers/ controllers/
COPY internal/ internal/
COPY encoding/ encoding/
COPY metalbond/ metalbond/
COPY netfns/ netfns/
COPY sysfs/ sysfs/
# Needed for version extraction by go build
COPY .git/ .git/
ARG TARGETOS
ARG TARGETARCH
# Build
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w -X main.buildVersion=$(git describe --tags)" -a -o manager main.go
FROM debian:bullseye-slim
WORKDIR /
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
RUN update-ca-certificates
COPY --from=builder /workspace/manager .
ENTRYPOINT ["/manager"]