forked from openshift/assisted-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.assisted-service
71 lines (54 loc) · 3.23 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
ARG BASE_TAG=stream9
# Generate python client
FROM quay.io/edge-infrastructure/swagger-codegen-cli:2.4.18 as swagger_py
COPY swagger.yaml .
COPY tools/generate_python_client.sh .
RUN chmod +x ./generate_python_client.sh && SWAGGER_FILE=swagger.yaml OUTPUT=/build ./generate_python_client.sh
FROM registry.access.redhat.com/ubi9/python-311:latest as pybuilder
COPY --chown=1001:0 . /assisted-service
COPY --from=swagger_py --chown=1001:0 /build /assisted-service/build
RUN python3 -m pip install -I pip && pip3 install -I -r /assisted-service/dev-requirements.txt
RUN cd /assisted-service/build && python3 ../tools/client_package_initializer.py ./ https://github.com/openshift/assisted-service
# TODO: Currently, the Python package is included in the service image for testing purposes. It conveniently allows matching a service version to a specific Python client version. In the future, once the Python package is published on pip, it should (probably) be removed from the Assisted Service image (this dockerfile).
# Build binaries
FROM quay.io/centos/centos:$BASE_TAG as builder
COPY hack/container_build_scripts/install_build_deps.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
# Create final image
FROM quay.io/centos/centos:$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
COPY --from=pybuilder /assisted-service/build/dist/* /clients/
ENV GODEBUG=madvdontneed=1
ENV GOGC=50
CMD ["/assisted-service"]