forked from openshift/assisted-service
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.assisted-service
91 lines (68 loc) · 3.16 KB
/
Dockerfile.assisted-service
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
ARG BASE_TAG=stream9
# Build binaries
FROM quay.io/centos/centos:$BASE_TAG as builder
COPY hack/container_build_scripts/install_build_deps.sh .
COPY hack/container_build_scripts/utils.sh .
ARG BASE_TAG
RUN ./install_build_deps.sh $BASE_TAG
COPY --from=registry.ci.openshift.org/openshift/release:golang-1.20 /usr/local/go /usr/local/go
ENV GOROOT=/usr/local/go
ENV PATH=$PATH:$GOROOT/bin
WORKDIR /assisted-service/
# Bring in the go dependencies before anything else so we can take
# advantage of caching these layers in future builds.
COPY api/go.mod api/go.sum /assisted-service/api/
COPY client/go.mod client/go.sum /assisted-service/client/
COPY models/go.mod models/go.sum /assisted-service/models/
COPY go.mod go.sum /assisted-service/
RUN go mod download
COPY . /assisted-service/
RUN cd cmd && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service
RUN cd ./cmd/operator && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-operator
RUN cd ./cmd/webadmission && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-admission
RUN cd ./cmd/agentbasedinstaller/client && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/agent-installer-client
# Licenses
FROM registry.access.redhat.com/ubi9/go-toolset:1.18 AS licenses
ADD . /app
WORKDIR /app
RUN go install github.com/google/[email protected]
RUN ${HOME}/go/bin/go-licenses save --save_path /tmp/licenses ./...
# Create final image
FROM quay.io/centos/centos:$BASE_TAG
ARG release=main
ARG version=latest
LABEL com.redhat.component assisted-service
LABEL description "Service that installs Openshift"
LABEL summary "Service that installs Openshift"
LABEL io.k8s.description "Service that installs Openshift"
LABEL distribution-scope public
LABEL name assisted-service
LABEL release ${release}
LABEL version ${version}
LABEL url https://github.com/openshift/assisted-service
LABEL vendor "Red Hat, Inc."
LABEL maintainer "Red Hat"
COPY --from=licenses /tmp/licenses /licenses
COPY hack/container_build_scripts/replace_dnf_repositories_ref_if_needed.sh .
COPY hack/container_build_scripts/utils.sh .
ARG BASE_TAG
RUN ./replace_dnf_repositories_ref_if_needed.sh $BASE_TAG
# multiarch images need it till WRKLDS-222 and https://bugzilla.redhat.com/show_bug.cgi?id=2111537 are fixed
RUN dnf install -y --setopt=install_weak_deps=False skopeo
# openshift-install requires this
RUN dnf install -y libvirt-libs nmstate nmstate-libs &&\
dnf clean all
RUN dnf update libksba libxml2 -y && dnf clean all
ARG WORK_DIR=/data
RUN mkdir $WORK_DIR && chmod 775 $WORK_DIR
# downstream this can be installed as an RPM
COPY --from=quay.io/openshift/origin-cli:4.12 /usr/bin/oc /usr/local/bin/
COPY --from=builder /build/assisted-service /assisted-service
COPY --from=builder /build/assisted-service-operator /assisted-service-operator
COPY --from=builder /build/assisted-service-admission /assisted-service-admission
COPY --from=builder /build/agent-installer-client /usr/local/bin/agent-installer-client
RUN ln -s /usr/local/bin/agent-installer-client /agent-based-installer-register-cluster-and-infraenv
ENV GODEBUG=madvdontneed=1
ENV GOGC=50
USER 1001:1001
CMD ["/assisted-service"]