-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
50 lines (42 loc) · 1.4 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
# Build the manager binary
FROM quay.io/centos/centos:stream9 AS builder
RUN yum install git jq -y && yum clean all
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# use latest Go z release
ENV GOTOOLCHAIN=auto
# Ensure correct Go version
RUN \
# get Go version from mod file
export GO_VERSION=$(grep -E "go [[:digit:]]\.[[:digit:]][[:digit:]]" go.mod | awk '{print $2}') && \
echo ${GO_VERSION} && \
# find filename for latest z version from Go download page
export GO_FILENAME=$(curl -sL 'https://go.dev/dl/?mode=json&include=all' | jq -r "[.[] | select(.version | startswith(\"go${GO_VERSION}\"))][0].files[] | select(.os == \"linux\" and .arch == \"amd64\") | .filename") && \
echo ${GO_FILENAME} && \
# download and unpack
curl -sL -o go.tar.gz "https://golang.org/dl/${GO_FILENAME}" && \
tar -C /usr/local -xzf go.tar.gz && \
rm go.tar.gz
# add Go to PATH
ENV PATH="/usr/local/go/bin:${PATH}"
RUN go version
# Copy the go source
COPY vendor/ vendor/
COPY version/ version/
COPY main.go main.go
COPY hack/ hack/
COPY api/ api/
COPY controllers/ controllers/
# for getting version info
COPY .git/ .git/
COPY pkg/ pkg/
COPY install/ install/
# Build
RUN ./hack/build.sh
FROM registry.access.redhat.com/ubi9/ubi:latest
WORKDIR /
COPY --from=builder /workspace/install/ install/
COPY --from=builder /workspace/bin/manager .
ENTRYPOINT ["/manager"]