diff --git a/.github/workflows/template-publish-image/action.yaml b/.github/workflows/template-publish-image/action.yaml index 53106172091..8bb73b3da94 100644 --- a/.github/workflows/template-publish-image/action.yaml +++ b/.github/workflows/template-publish-image/action.yaml @@ -12,7 +12,7 @@ runs: using: composite steps: - name: Set Up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Docker Login uses: docker/login-action@v1 @@ -30,7 +30,7 @@ runs: type=sha,prefix=v1beta1- - name: Build and Push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . file: ${{ inputs.dockerfile }} @@ -38,3 +38,4 @@ runs: tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max + platforms: linux/amd64 diff --git a/.github/workflows/template-setup-e2e-test/action.yaml b/.github/workflows/template-setup-e2e-test/action.yaml index b060c8b966e..10e66b2b430 100644 --- a/.github/workflows/template-setup-e2e-test/action.yaml +++ b/.github/workflows/template-setup-e2e-test/action.yaml @@ -17,7 +17,7 @@ runs: github token: ${{ env.GITHUB_TOKEN }} - name: Set Up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Set Up Go env uses: actions/setup-go@v2 diff --git a/.github/workflows/test-charmed-katib.yaml b/.github/workflows/test-charmed-katib.yaml index 447ba25c848..5e7da2091cf 100644 --- a/.github/workflows/test-charmed-katib.yaml +++ b/.github/workflows/test-charmed-katib.yaml @@ -49,15 +49,19 @@ jobs: sudo snap install juju-wait --classic sudo pip3 install charmcraft==1.3.1 + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build Docker images run: | set -eux images=("katib-controller" "katib-ui" "katib-db-manager") folders=("katib-controller" "ui" "db-manager") for idx in {0..2}; do - docker build . \ + docker buildx build . \ -t docker.io/kubeflowkatib/${images[$idx]}:latest \ - -f cmd/${folders[$idx]}/v1beta1/Dockerfile + -f cmd/${folders[$idx]}/v1beta1/Dockerfile \ + --load docker save docker.io/kubeflowkatib/${images[$idx]} > ${images[$idx]}.tar microk8s ctr image import ${images[$idx]}.tar done diff --git a/cmd/cert-generator/v1beta1/Dockerfile b/cmd/cert-generator/v1beta1/Dockerfile index e8a9b2e6a12..3984005a8c1 100644 --- a/cmd/cert-generator/v1beta1/Dockerfile +++ b/cmd/cert-generator/v1beta1/Dockerfile @@ -1,6 +1,8 @@ -# Build the Katib Cert Generatoe. +# Build the Katib Cert Generator. FROM golang:alpine AS build-env +ARG TARGETARCH + WORKDIR /go/src/github.com/kubeflow/katib # Download packages. @@ -13,13 +15,7 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o katib-cert-generator ./cmd/cert-generator/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o katib-cert-generator ./cmd/cert-generator/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o katib-cert-generator ./cmd/cert-generator/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o katib-cert-generator ./cmd/cert-generator/v1beta1 # Copy the cert-generator into a thin image. FROM gcr.io/distroless/static:nonroot diff --git a/cmd/db-manager/v1beta1/Dockerfile b/cmd/db-manager/v1beta1/Dockerfile index d36cdd10077..7dae3cb5de2 100644 --- a/cmd/db-manager/v1beta1/Dockerfile +++ b/cmd/db-manager/v1beta1/Dockerfile @@ -1,6 +1,7 @@ # Build the Katib DB manager. FROM golang:alpine AS build-env +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 WORKDIR /go/src/github.com/kubeflow/katib @@ -15,23 +16,11 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o katib-db-manager ./cmd/db-manager/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o katib-db-manager ./cmd/db-manager/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o katib-db-manager ./cmd/db-manager/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -a -o katib-db-manager ./cmd/db-manager/v1beta1 # Add GRPC health probe. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe +RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe # Copy the db-manager into a thin image. FROM alpine:3.15 diff --git a/cmd/earlystopping/medianstop/v1beta1/Dockerfile b/cmd/earlystopping/medianstop/v1beta1/Dockerfile index 5f51a61b2fd..1a5ebd35e2a 100644 --- a/cmd/earlystopping/medianstop/v1beta1/Dockerfile +++ b/cmd/earlystopping/medianstop/v1beta1/Dockerfile @@ -1,9 +1,11 @@ FROM python:3.9-slim +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV EARLY_STOPPING_DIR cmd/earlystopping/medianstop/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "arm64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ @@ -12,12 +14,11 @@ RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${EARLY_STOPPING_DIR}/ ${TARGET_DIR}/${EARLY_STOPPING_DIR}/ + WORKDIR ${TARGET_DIR}/${EARLY_STOPPING_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/katib-controller/v1beta1/Dockerfile b/cmd/katib-controller/v1beta1/Dockerfile index df056452533..158c1cd8275 100644 --- a/cmd/katib-controller/v1beta1/Dockerfile +++ b/cmd/katib-controller/v1beta1/Dockerfile @@ -1,6 +1,8 @@ # Build the Katib controller. FROM golang:alpine AS build-env +ARG TARGETARCH + WORKDIR /go/src/github.com/kubeflow/katib # Download packages. @@ -13,13 +15,7 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o katib-controller ./cmd/katib-controller/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o katib-controller ./cmd/katib-controller/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o katib-controller ./cmd/katib-controller/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o katib-controller ./cmd/katib-controller/v1beta1 # Copy the controller-manager into a thin image. FROM alpine:3.15 diff --git a/cmd/metricscollector/v1beta1/file-metricscollector/Dockerfile b/cmd/metricscollector/v1beta1/file-metricscollector/Dockerfile index 88544685d37..00004363b25 100644 --- a/cmd/metricscollector/v1beta1/file-metricscollector/Dockerfile +++ b/cmd/metricscollector/v1beta1/file-metricscollector/Dockerfile @@ -1,6 +1,8 @@ # Build the Katib file metrics collector. FROM golang:alpine AS build-env +ARG TARGETARCH + WORKDIR /go/src/github.com/kubeflow/katib # Download packages. @@ -13,13 +15,7 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o file-metricscollector ./cmd/metricscollector/v1beta1/file-metricscollector; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o file-metricscollector ./cmd/metricscollector/v1beta1/file-metricscollector; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o file-metricscollector ./cmd/metricscollector/v1beta1/file-metricscollector; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o file-metricscollector ./cmd/metricscollector/v1beta1/file-metricscollector # Copy the file metrics collector into a thin image. FROM alpine:3.15 diff --git a/cmd/metricscollector/v1beta1/tfevent-metricscollector/Dockerfile b/cmd/metricscollector/v1beta1/tfevent-metricscollector/Dockerfile index fc26dfdfcd9..c5ff6427ec3 100644 --- a/cmd/metricscollector/v1beta1/tfevent-metricscollector/Dockerfile +++ b/cmd/metricscollector/v1beta1/tfevent-metricscollector/Dockerfile @@ -1,13 +1,16 @@ FROM python:3.9-slim +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV METRICS_COLLECTOR_DIR cmd/metricscollector/v1beta1/tfevent-metricscollector +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/metricscollector/v1beta1/tfevent-metricscollector/::${TARGET_DIR}/pkg/metricscollector/v1beta1/common/ ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${METRICS_COLLECTOR_DIR}/ ${TARGET_DIR}/${METRICS_COLLECTOR_DIR}/ + WORKDIR ${TARGET_DIR}/${METRICS_COLLECTOR_DIR} -RUN if [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "arm64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libpcre3 libpcre3-dev && \ apt-get clean && \ @@ -15,10 +18,7 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \ fi RUN pip install --no-cache-dir -r requirements.txt - RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/metricscollector/v1beta1/tfevent-metricscollector/::${TARGET_DIR}/pkg/metricscollector/v1beta1/common/ - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/new-ui/v1beta1/Dockerfile b/cmd/new-ui/v1beta1/Dockerfile index b9130b4478b..8a513a138a3 100644 --- a/cmd/new-ui/v1beta1/Dockerfile +++ b/cmd/new-ui/v1beta1/Dockerfile @@ -35,6 +35,8 @@ RUN npm run build:prod # --- Build the backend --- FROM golang:alpine AS go-build +ARG TARGETARCH + WORKDIR /go/src/github.com/kubeflow/katib # Download packages. @@ -47,13 +49,7 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o katib-ui ./cmd/new-ui/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o katib-ui ./cmd/new-ui/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o katib-ui ./cmd/new-ui/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o katib-ui ./cmd/new-ui/v1beta1 # --- Compose the web app --- FROM alpine:3.15 diff --git a/cmd/suggestion/chocolate/v1beta1/Dockerfile b/cmd/suggestion/chocolate/v1beta1/Dockerfile index 4be183490a1..bff97750af4 100644 --- a/cmd/suggestion/chocolate/v1beta1/Dockerfile +++ b/cmd/suggestion/chocolate/v1beta1/Dockerfile @@ -1,21 +1,21 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/chocolate/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python RUN apt-get -y update && \ apt-get -y install git && \ - if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ + if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "arm64" ]; then \ apt-get -y install gfortran libopenblas-dev liblapack-dev g++; \ fi && \ apt-get clean && \ @@ -26,11 +26,9 @@ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/goptuna/v1beta1/Dockerfile b/cmd/suggestion/goptuna/v1beta1/Dockerfile index ffd68e20926..440a2f610af 100644 --- a/cmd/suggestion/goptuna/v1beta1/Dockerfile +++ b/cmd/suggestion/goptuna/v1beta1/Dockerfile @@ -1,6 +1,7 @@ # Build the Goptuna Suggestion. FROM golang:alpine AS build-env +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 WORKDIR /go/src/github.com/kubeflow/katib @@ -15,23 +16,11 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o goptuna-suggestion ./cmd/suggestion/goptuna/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o goptuna-suggestion ./cmd/suggestion/goptuna/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o goptuna-suggestion ./cmd/suggestion/goptuna/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o goptuna-suggestion ./cmd/suggestion/goptuna/v1beta1 # Add GRPC health probe. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe # Copy the Goptuna suggestion into a thin image. FROM alpine:3.15 @@ -39,6 +28,7 @@ FROM alpine:3.15 ENV TARGET_DIR /opt/katib WORKDIR ${TARGET_DIR} + COPY --from=build-env /bin/grpc_health_probe /bin/ COPY --from=build-env /go/src/github.com/kubeflow/katib/goptuna-suggestion ${TARGET_DIR}/ diff --git a/cmd/suggestion/hyperband/v1beta1/Dockerfile b/cmd/suggestion/hyperband/v1beta1/Dockerfile index 79e8572b597..c116991242b 100644 --- a/cmd/suggestion/hyperband/v1beta1/Dockerfile +++ b/cmd/suggestion/hyperband/v1beta1/Dockerfile @@ -1,19 +1,19 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/hyperband/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "arm64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ @@ -25,11 +25,9 @@ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/hyperopt/v1beta1/Dockerfile b/cmd/suggestion/hyperopt/v1beta1/Dockerfile index 6d69588692a..2324c12753c 100644 --- a/cmd/suggestion/hyperopt/v1beta1/Dockerfile +++ b/cmd/suggestion/hyperopt/v1beta1/Dockerfile @@ -1,19 +1,19 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/hyperopt/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ @@ -25,11 +25,9 @@ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/nas/darts/v1beta1/Dockerfile b/cmd/suggestion/nas/darts/v1beta1/Dockerfile index 173371fbf67..e94341f0779 100644 --- a/cmd/suggestion/nas/darts/v1beta1/Dockerfile +++ b/cmd/suggestion/nas/darts/v1beta1/Dockerfile @@ -1,19 +1,19 @@ FROM alpine:3.15 as downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/nas/darts/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ @@ -25,11 +25,9 @@ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/nas/enas/v1beta1/Dockerfile b/cmd/suggestion/nas/enas/v1beta1/Dockerfile index 7ae66e87f71..639d21b2750 100644 --- a/cmd/suggestion/nas/enas/v1beta1/Dockerfile +++ b/cmd/suggestion/nas/enas/v1beta1/Dockerfile @@ -1,20 +1,20 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/nas/enas/v1beta1 ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ @@ -26,11 +26,9 @@ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/optuna/v1beta1/Dockerfile b/cmd/suggestion/optuna/v1beta1/Dockerfile index 3d445c883b2..7b7129f7f44 100644 --- a/cmd/suggestion/optuna/v1beta1/Dockerfile +++ b/cmd/suggestion/optuna/v1beta1/Dockerfile @@ -1,34 +1,33 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/optuna/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*; \ fi + ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/pbt/v1beta1/Dockerfile b/cmd/suggestion/pbt/v1beta1/Dockerfile index 06f56c90c2d..e969ee39c21 100644 --- a/cmd/suggestion/pbt/v1beta1/Dockerfile +++ b/cmd/suggestion/pbt/v1beta1/Dockerfile @@ -1,37 +1,33 @@ +FROM alpine:3.15 AS downloader + +ARG TARGETARCH +ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 + +RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe + FROM python:3.9-slim +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/pbt/v1beta1 -ENV GRPC_HEALTH_PROBE_VERSION v0.4.6 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ - apt-get -y update && \ - apt-get -y install gfortran libopenblas-dev liblapack-dev wget && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/*; \ - else \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ - apt-get -y install wget && \ + apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*; \ fi -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ +COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe + WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/suggestion/skopt/v1beta1/Dockerfile b/cmd/suggestion/skopt/v1beta1/Dockerfile index 7e683a9d8e7..a0f934fafbf 100644 --- a/cmd/suggestion/skopt/v1beta1/Dockerfile +++ b/cmd/suggestion/skopt/v1beta1/Dockerfile @@ -1,34 +1,33 @@ FROM alpine:3.15 AS downloader + +ARG TARGETARCH ENV GRPC_HEALTH_PROBE_VERSION v0.4.11 -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-ppc64le; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64; \ - else \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64; \ - fi && \ - chmod +x /bin/grpc_health_probe + +RUN wget -qO /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH} \ + && chmod +x /bin/grpc_health_probe FROM python:3.9-slim + +ARG TARGETARCH ENV TARGET_DIR /opt/katib ENV SUGGESTION_DIR cmd/suggestion/skopt/v1beta1 +ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python -RUN if [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "ppc64le" ] || [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libopenblas-dev liblapack-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*; \ fi + ADD ./pkg/ ${TARGET_DIR}/pkg/ ADD ./${SUGGESTION_DIR}/ ${TARGET_DIR}/${SUGGESTION_DIR}/ COPY --from=downloader /bin/grpc_health_probe /bin/grpc_health_probe WORKDIR ${TARGET_DIR}/${SUGGESTION_DIR} -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt RUN chgrp -R 0 ${TARGET_DIR} \ && chmod -R g+rwX ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR}:${TARGET_DIR}/pkg/apis/manager/v1beta1/python:${TARGET_DIR}/pkg/apis/manager/health/python - ENTRYPOINT ["python", "main.py"] diff --git a/cmd/ui/v1beta1/Dockerfile b/cmd/ui/v1beta1/Dockerfile index 5a9a1ab0bad..505cc7eada8 100644 --- a/cmd/ui/v1beta1/Dockerfile +++ b/cmd/ui/v1beta1/Dockerfile @@ -10,6 +10,8 @@ RUN rm -rf /frontend/node_modules # Build backend. FROM golang:alpine AS go-build +ARG TARGETARCH + WORKDIR /go/src/github.com/kubeflow/katib # Download packages. @@ -22,13 +24,7 @@ COPY cmd/ cmd/ COPY pkg/ pkg/ # Build the binary. -RUN if [ "$(uname -m)" = "ppc64le" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -a -o katib-ui ./cmd/ui/v1beta1; \ - elif [ "$(uname -m)" = "aarch64" ]; then \ - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -o katib-ui ./cmd/ui/v1beta1; \ - else \ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o katib-ui ./cmd/ui/v1beta1; \ - fi +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o katib-ui ./cmd/ui/v1beta1 # Copy the backend and frontend into a thin image. FROM alpine:3.15 diff --git a/docs/developer-guide.md b/docs/developer-guide.md index 2585042c0da..93bed7c9963 100644 --- a/docs/developer-guide.md +++ b/docs/developer-guide.md @@ -14,6 +14,7 @@ see the following user guides: - [Go](https://golang.org/) (1.18 or later) - [Docker](https://docs.docker.com/) (20.10 or later) +- [Docker Buildx](https://docs.docker.com/build/buildx/) (0.8.0 or later) - [Java](https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html) (8 or later) - [Python](https://www.python.org/) (3.9 or later) - [kustomize](https://kustomize.io/) (4.0.5 or later) diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.cpu b/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.cpu index bf7160a40cd..067628cf06e 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.cpu +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.cpu @@ -3,6 +3,7 @@ FROM python:3.9-slim ENV TARGET_DIR /opt/darts-cnn-cifar10 ADD examples/v1beta1/trial-images/darts-cnn-cifar10 ${TARGET_DIR} + WORKDIR ${TARGET_DIR} RUN pip install --no-cache-dir -r requirements.txt diff --git a/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.gpu b/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.gpu index 903516fc01d..819b8fb77fa 100644 --- a/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.gpu +++ b/examples/v1beta1/trial-images/darts-cnn-cifar10/Dockerfile.gpu @@ -5,6 +5,7 @@ FROM pytorch/pytorch:1.0-cuda${cuda_version}-cudnn${cudnn_version}-runtime ENV TARGET_DIR /opt/darts-cnn-cifar10 ADD examples/v1beta1/trial-images/darts-cnn-cifar10 ${TARGET_DIR} + WORKDIR ${TARGET_DIR} RUN chgrp -R 0 ${TARGET_DIR} \ diff --git a/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.cpu b/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.cpu index 4b693640e7c..8eec13594d6 100644 --- a/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.cpu +++ b/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.cpu @@ -1,13 +1,14 @@ FROM python:3.9-slim +ARG TARGETARCH ENV TARGET_DIR /opt/enas-cnn-cifar10 +ENV PYTHONPATH ${TARGET_DIR} ADD examples/v1beta1/trial-images/enas-cnn-cifar10 ${TARGET_DIR} -WORKDIR ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR} +WORKDIR ${TARGET_DIR} -RUN if [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libpcre3 libpcre3-dev && \ apt-get clean && \ diff --git a/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.gpu b/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.gpu index fb37258ea8a..f7071a4f759 100644 --- a/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.gpu +++ b/examples/v1beta1/trial-images/enas-cnn-cifar10/Dockerfile.gpu @@ -1,11 +1,11 @@ FROM tensorflow/tensorflow:2.9.1-gpu ENV TARGET_DIR /opt/enas-cnn-cifar10 +ENV PYTHONPATH ${TARGET_DIR} ADD examples/v1beta1/trial-images/enas-cnn-cifar10 ${TARGET_DIR} -WORKDIR ${TARGET_DIR} -ENV PYTHONPATH ${TARGET_DIR} +WORKDIR ${TARGET_DIR} RUN pip install --no-cache-dir scipy==1.8.1 RUN chgrp -R 0 ${TARGET_DIR} \ diff --git a/examples/v1beta1/trial-images/mxnet-mnist/Dockerfile b/examples/v1beta1/trial-images/mxnet-mnist/Dockerfile index a229f847207..4c46894aa1a 100644 --- a/examples/v1beta1/trial-images/mxnet-mnist/Dockerfile +++ b/examples/v1beta1/trial-images/mxnet-mnist/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.9-slim ADD examples/v1beta1/trial-images/mxnet-mnist /opt/mxnet-mnist + WORKDIR /opt/mxnet-mnist RUN apt-get -y update \ diff --git a/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.cpu b/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.cpu index 8780095f9e2..1ebab4fa036 100644 --- a/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.cpu +++ b/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.cpu @@ -1,6 +1,7 @@ FROM python:3.9-slim ADD examples/v1beta1/trial-images/pytorch-mnist /opt/pytorch-mnist + WORKDIR /opt/pytorch-mnist # Add folder for the logs. diff --git a/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.gpu b/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.gpu index cdb6190f247..0cc37f2cd5d 100644 --- a/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.gpu +++ b/examples/v1beta1/trial-images/pytorch-mnist/Dockerfile.gpu @@ -1,6 +1,7 @@ FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime ADD examples/v1beta1/trial-images/pytorch-mnist /opt/pytorch-mnist + WORKDIR /opt/pytorch-mnist # Add folder for the logs. diff --git a/examples/v1beta1/trial-images/simple-pbt/Dockerfile b/examples/v1beta1/trial-images/simple-pbt/Dockerfile index 4f024455998..f7285447c14 100644 --- a/examples/v1beta1/trial-images/simple-pbt/Dockerfile +++ b/examples/v1beta1/trial-images/simple-pbt/Dockerfile @@ -1,10 +1,10 @@ FROM python:3.9-slim ADD examples/v1beta1/trial-images/simple-pbt /opt/pbt + WORKDIR /opt/pbt RUN python3 -m pip install -r requirements.txt - RUN chgrp -R 0 /opt/pbt \ && chmod -R g+rwX /opt/pbt diff --git a/examples/v1beta1/trial-images/tf-mnist-with-summaries/Dockerfile b/examples/v1beta1/trial-images/tf-mnist-with-summaries/Dockerfile index 74919c6ad09..7a78a66fea6 100644 --- a/examples/v1beta1/trial-images/tf-mnist-with-summaries/Dockerfile +++ b/examples/v1beta1/trial-images/tf-mnist-with-summaries/Dockerfile @@ -1,9 +1,12 @@ FROM python:3.9-slim +ARG TARGETARCH + ADD examples/v1beta1/trial-images/tf-mnist-with-summaries /opt/tf-mnist-with-summaries + WORKDIR /opt/tf-mnist-with-summaries -RUN if [ "$(uname -m)" = "aarch64" ]; then \ +RUN if [ "${TARGETARCH}" = "aarch64" ]; then \ apt-get -y update && \ apt-get -y install gfortran libpcre3 libpcre3-dev && \ apt-get clean && \ diff --git a/scripts/v1beta1/build.sh b/scripts/v1beta1/build.sh index da6f9723731..93f74430748 100755 --- a/scripts/v1beta1/build.sh +++ b/scripts/v1beta1/build.sh @@ -56,63 +56,63 @@ cd "${SCRIPT_ROOT}" # Katib core images echo -e "\nBuilding Katib controller image...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/katib-controller:${TAG}" -f ${CMD_PREFIX}/katib-controller/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/katib-controller:${TAG}" -f ${CMD_PREFIX}/katib-controller/${VERSION}/Dockerfile . echo -e "\nBuilding Katib DB manager image...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/katib-db-manager:${TAG}" -f ${CMD_PREFIX}/db-manager/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/katib-db-manager:${TAG}" -f ${CMD_PREFIX}/db-manager/${VERSION}/Dockerfile . # TODO (andreyvelich): Switch to ${CMD_PREFIX}/ui/${VERSION}/Dockerfile once old UI is deprecated. echo -e "\nBuilding Katib UI image...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/katib-ui:${TAG}" -f ${CMD_PREFIX}/new-ui/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/katib-ui:${TAG}" -f ${CMD_PREFIX}/new-ui/${VERSION}/Dockerfile . echo -e "\nBuilding Katib cert generator image...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/cert-generator:${TAG}" -f ${CMD_PREFIX}/cert-generator/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/cert-generator:${TAG}" -f ${CMD_PREFIX}/cert-generator/${VERSION}/Dockerfile . echo -e "\nBuilding file metrics collector image...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/file-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/file-metricscollector/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/file-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/file-metricscollector/Dockerfile . echo -e "\nBuilding TF Event metrics collector image...\n" if [ "$ARCH" == "ppc64le" ]; then - docker build --platform "linux/$ARCH" -t "${REGISTRY}/tfevent-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile.ppc64le . + docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/tfevent-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile.ppc64le . else - docker build --platform "linux/$ARCH" -t "${REGISTRY}/tfevent-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile . + docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/tfevent-metrics-collector:${TAG}" -f ${CMD_PREFIX}/metricscollector/${VERSION}/tfevent-metricscollector/Dockerfile . fi # Suggestion images echo -e "\nBuilding suggestion images..." echo -e "\nBuilding hyperopt suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-hyperopt:${TAG}" -f ${CMD_PREFIX}/suggestion/hyperopt/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-hyperopt:${TAG}" -f ${CMD_PREFIX}/suggestion/hyperopt/${VERSION}/Dockerfile . echo -e "\nBuilding chocolate suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-chocolate:${TAG}" -f ${CMD_PREFIX}/suggestion/chocolate/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-chocolate:${TAG}" -f ${CMD_PREFIX}/suggestion/chocolate/${VERSION}/Dockerfile . echo -e "\nBuilding hyperband suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-hyperband:${TAG}" -f ${CMD_PREFIX}/suggestion/hyperband/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-hyperband:${TAG}" -f ${CMD_PREFIX}/suggestion/hyperband/${VERSION}/Dockerfile . echo -e "\nBuilding skopt suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-skopt:${TAG}" -f ${CMD_PREFIX}/suggestion/skopt/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-skopt:${TAG}" -f ${CMD_PREFIX}/suggestion/skopt/${VERSION}/Dockerfile . echo -e "\nBuilding goptuna suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-goptuna:${TAG}" -f ${CMD_PREFIX}/suggestion/goptuna/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-goptuna:${TAG}" -f ${CMD_PREFIX}/suggestion/goptuna/${VERSION}/Dockerfile . echo -e "\nBuilding optuna suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-optuna:${TAG}" -f ${CMD_PREFIX}/suggestion/optuna/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-optuna:${TAG}" -f ${CMD_PREFIX}/suggestion/optuna/${VERSION}/Dockerfile . echo -e "\nBuilding ENAS suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-enas:${TAG}" -f ${CMD_PREFIX}/suggestion/nas/enas/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-enas:${TAG}" -f ${CMD_PREFIX}/suggestion/nas/enas/${VERSION}/Dockerfile . echo -e "\nBuilding DARTS suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-darts:${TAG}" -f ${CMD_PREFIX}/suggestion/nas/darts/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-darts:${TAG}" -f ${CMD_PREFIX}/suggestion/nas/darts/${VERSION}/Dockerfile . echo -e "\nBuilding PBT suggestion...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-pbt:${TAG}" -f ${CMD_PREFIX}/suggestion/pbt/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/suggestion-pbt:${TAG}" -f ${CMD_PREFIX}/suggestion/pbt/${VERSION}/Dockerfile . # Early stopping images echo -e "\nBuilding early stopping images...\n" echo -e "\nBuilding median stopping rule...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/earlystopping-medianstop:${TAG}" -f ${CMD_PREFIX}/earlystopping/medianstop/${VERSION}/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/earlystopping-medianstop:${TAG}" -f ${CMD_PREFIX}/earlystopping/medianstop/${VERSION}/Dockerfile . # Training container images echo -e "\nBuilding training container images..." @@ -121,31 +121,31 @@ if [ ! "$ARCH" = "amd64" ]; then echo -e "\nSome training container images are supported only amd64." else echo -e "\nBuilding mxnet mnist training container example...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/mxnet-mnist:${TAG}" -f examples/${VERSION}/trial-images/mxnet-mnist/Dockerfile . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/mxnet-mnist:${TAG}" -f examples/${VERSION}/trial-images/mxnet-mnist/Dockerfile . echo -e "\nBuilding PyTorch mnist training container example with CPU support...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/pytorch-mnist-cpu:${TAG}" -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile.cpu . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/pytorch-mnist-cpu:${TAG}" -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile.cpu . echo -e "\nBuilding PyTorch mnist training container example with GPU support...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/pytorch-mnist-gpu:${TAG}" -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile.gpu . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/pytorch-mnist-gpu:${TAG}" -f examples/${VERSION}/trial-images/pytorch-mnist/Dockerfile.gpu . echo -e "\nBuilding Keras CIFAR-10 CNN training container example for ENAS with GPU support...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/enas-cnn-cifar10-gpu:${TAG}" -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.gpu . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/enas-cnn-cifar10-gpu:${TAG}" -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.gpu . echo -e "\nBuilding PyTorch CIFAR-10 CNN training container example for DARTS with CPU support...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/darts-cnn-cifar10-cpu:${TAG}" -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile.cpu . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/darts-cnn-cifar10-cpu:${TAG}" -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile.cpu . echo -e "\nBuilding PyTorch CIFAR-10 CNN training container example for DARTS with GPU support...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/darts-cnn-cifar10-gpu:${TAG}" -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile.gpu . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/darts-cnn-cifar10-gpu:${TAG}" -f examples/${VERSION}/trial-images/darts-cnn-cifar10/Dockerfile.gpu . echo -e "\nBuilding dynamic learning rate training container example for PBT...\n" - docker build --platform linux/amd64 -t "${REGISTRY}/simple-pbt:${TAG}" -f examples/${VERSION}/trial-images/simple-pbt/Dockerfile . + docker buildx build --platform linux/amd64 -t "${REGISTRY}/simple-pbt:${TAG}" -f examples/${VERSION}/trial-images/simple-pbt/Dockerfile . fi echo -e "\nBuilding Tensorflow with summaries mnist training container example...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/tf-mnist-with-summaries:${TAG}" -f examples/${VERSION}/trial-images/tf-mnist-with-summaries/Dockerfile . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/tf-mnist-with-summaries:${TAG}" -f examples/${VERSION}/trial-images/tf-mnist-with-summaries/Dockerfile . echo -e "\nBuilding Keras CIFAR-10 CNN training container example for ENAS with CPU support...\n" -docker build --platform "linux/$ARCH" -t "${REGISTRY}/enas-cnn-cifar10-cpu:${TAG}" -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.cpu . +docker buildx build --platform "linux/$ARCH" -t "${REGISTRY}/enas-cnn-cifar10-cpu:${TAG}" -f examples/${VERSION}/trial-images/enas-cnn-cifar10/Dockerfile.cpu . echo -e "\nAll Katib images with ${TAG} tag have been built successfully!\n" diff --git a/test/e2e/v1beta1/scripts/gh-actions/build-load.sh b/test/e2e/v1beta1/scripts/gh-actions/build-load.sh index 30fae899236..30dc2f2f159 100755 --- a/test/e2e/v1beta1/scripts/gh-actions/build-load.sh +++ b/test/e2e/v1beta1/scripts/gh-actions/build-load.sh @@ -48,7 +48,7 @@ _build_containers() { done echo -e "\nBuilding $CONTAINER_NAME image with $DOCKERFILE...\n" - docker build --platform "$(uname -m)" -t "$REGISTRY/$CONTAINER_NAME:$TAG" -f "../../../../../$DOCKERFILE" ../../../../../ + docker buildx build --platform "$(uname -m)" --load -t "$REGISTRY/$CONTAINER_NAME:$TAG" -f "../../../../../$DOCKERFILE" ../../../../../ } _load_minikube_cluster() {