forked from openshift/assisted-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.assisted-service
64 lines (49 loc) · 3.03 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
# 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
# TODO: Find a pure Python3 base image, rather than relying on the golang one
FROM registry.ci.openshift.org/openshift/release:golang-1.17 as pybuilder
COPY . /assisted-service
COPY --from=swagger_py /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:stream9 as builder
RUN dnf install -y gcc && dnf clean all
COPY --from=registry.ci.openshift.org/openshift/release:golang-1.17 /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 models/go.mod models/go.sum /assisted-service/models/
COPY go.mod go.sum /assisted-service/
RUN go mod download
COPY . /assisted-service/
RUN CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service cmd/main.go
RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-operator cmd/operator/main.go
RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-admission cmd/webadmission/main.go
RUN CGO_ENABLED=0 GOFLAGS="" GO111MODULE=on go build -o /build/agent-installer-client cmd/agentbasedinstaller/client/main.go
# Create final image
FROM quay.io/centos/centos:stream8
# openshift-install requires this
RUN dnf install -y libvirt-libs nmstate &&\
dnf clean all
ARG WORK_DIR=/data
RUN mkdir $WORK_DIR && chmod 775 $WORK_DIR
# downstream this can be installed as an RPM
ARG OC_URL=https://mirror.openshift.com/pub/openshift-v4/clients/ocp-dev-preview/4.12.0-0.nightly-2022-07-11-054352/openshift-client-linux.tar.gz
RUN curl --retry 5 -s $OC_URL | tar -xzC /usr/local/bin/ oc
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"]