|
1 |
| -# Copyright 2021-2024 The Kubeflow Authors |
| 1 | +# Copyright 2021-2022 The Kubeflow Authors |
2 | 2 | #
|
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | # you may not use this file except in compliance with the License.
|
|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 |
| -# Build arguments |
16 |
| -ARG SOURCE_CODE=. |
| 15 | +# 1. Build api server application |
| 16 | +FROM golang:1.21.7-bookworm as builder |
| 17 | +RUN apt-get update && apt-get install -y cmake clang musl-dev openssl |
| 18 | +WORKDIR /go/src/github.com/kubeflow/pipelines |
| 19 | +COPY . . |
| 20 | +RUN GO111MODULE=on go build -o /bin/apiserver backend/src/apiserver/*.go |
| 21 | +# Check licenses and comply with license terms. |
| 22 | +RUN ./hack/install-go-licenses.sh |
| 23 | +# First, make sure there's no forbidden license. |
| 24 | +RUN go-licenses check ./backend/src/apiserver |
| 25 | +RUN go-licenses csv ./backend/src/apiserver > /tmp/licenses.csv && \ |
| 26 | + diff /tmp/licenses.csv backend/third_party_licenses/apiserver.csv && \ |
| 27 | + go-licenses save ./backend/src/apiserver --save_path /tmp/NOTICES |
| 28 | + |
| 29 | +# 2. Compile preloaded pipeline samples |
| 30 | +FROM python:3.8 as compiler |
| 31 | +RUN apt-get update -y && apt-get install --no-install-recommends -y -q default-jdk python3-setuptools python3-dev jq |
| 32 | +RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py |
| 33 | +COPY backend/requirements.txt . |
| 34 | +RUN python3 -m pip install -r requirements.txt --no-cache-dir |
17 | 35 |
|
18 |
| -FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as builder |
19 |
| - |
20 |
| -USER root |
21 | 36 | # Downloading Argo CLI so that the samples are validated
|
22 | 37 | ENV ARGO_VERSION v3.4.17
|
23 | 38 | RUN curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz && \
|
24 | 39 | gunzip argo-linux-amd64.gz && \
|
25 | 40 | chmod +x argo-linux-amd64 && \
|
26 | 41 | mv ./argo-linux-amd64 /usr/local/bin/argo
|
27 | 42 |
|
28 |
| -RUN dnf install -y cmake clang openssl |
29 |
| - |
30 |
| -COPY ${SOURCE_CODE}/go.mod ./ |
31 |
| -COPY ${SOURCE_CODE}/go.sum ./ |
| 43 | +WORKDIR / |
| 44 | +COPY ./samples /samples |
| 45 | +COPY backend/src/apiserver/config/sample_config.json /samples/ |
32 | 46 |
|
33 |
| -RUN GO111MODULE=on go mod download |
| 47 | +# Compiling the preloaded samples. |
| 48 | +# The default image is replaced with the GCR-hosted python image. |
| 49 | +RUN set -e; \ |
| 50 | + < /samples/sample_config.json jq .[].file --raw-output | while read pipeline_yaml; do \ |
| 51 | + pipeline_py="${pipeline_yaml%.yaml}"; \ |
| 52 | + python3 "$pipeline_py"; \ |
| 53 | + done |
34 | 54 |
|
35 |
| -# Copy the source |
36 |
| -COPY ${SOURCE_CODE}/ ./ |
| 55 | +# 3. Start api web server |
| 56 | +FROM debian:stable |
37 | 57 |
|
38 |
| -RUN GO111MODULE=on go build -o /bin/apiserver ./backend/src/apiserver/ && \ |
39 |
| - dnf clean all |
40 |
| - |
41 |
| -FROM registry.access.redhat.com/ubi8/ubi-minimal:latest |
| 58 | +ARG COMMIT_SHA=unknown |
| 59 | +ENV COMMIT_SHA=${COMMIT_SHA} |
| 60 | +ARG TAG_NAME=unknown |
| 61 | +ENV TAG_NAME=${TAG_NAME} |
| 62 | +ENV LOG_LEVEL info |
42 | 63 |
|
43 | 64 | WORKDIR /bin
|
44 | 65 |
|
45 |
| -COPY --from=builder /opt/app-root/src/backend/src/apiserver/config/ /config |
| 66 | +COPY backend/src/apiserver/config/ /config |
46 | 67 | COPY --from=builder /bin/apiserver /bin/apiserver
|
47 | 68 |
|
| 69 | +# Copy licenses and notices. |
| 70 | +COPY --from=builder /tmp/licenses.csv /third_party/licenses.csv |
| 71 | +COPY --from=builder /tmp/NOTICES /third_party/NOTICES |
| 72 | +COPY --from=compiler /samples/ /samples/ |
48 | 73 | RUN chmod +x /bin/apiserver
|
49 | 74 |
|
50 |
| -USER root |
51 |
| - |
52 | 75 | # Adding CA certificate so API server can download pipeline through URL and wget is used for liveness/readiness probe command
|
53 |
| -RUN microdnf install -y ca-certificates wget |
| 76 | +RUN apt-get update && apt-get install -y ca-certificates wget |
54 | 77 |
|
55 |
| -USER 1001 |
| 78 | +# Pin sample doc links to the commit that built the backend image |
| 79 | +RUN sed -E "s#/(blob|tree)/master/#/\1/${COMMIT_SHA}/#g" -i /config/sample_config.json && \ |
| 80 | + sed -E "s/%252Fmaster/%252F${COMMIT_SHA}/#g" -i /config/sample_config.json |
56 | 81 |
|
57 | 82 | # Expose apiserver port
|
58 | 83 | EXPOSE 8888
|
|
0 commit comments