From edaf2374b085f8c8c17117aa925da07927df38d1 Mon Sep 17 00:00:00 2001 From: "Hui, Chunyang" Date: Mon, 27 Sep 2021 07:44:48 +0000 Subject: [PATCH] Support building CI image for different branches --- .github/workflows/build_and_push_ci_image.yml | 32 +++++++++++++++++-- tools/docker/ci/Dockerfile.openvino | 3 +- tools/docker/ci/Dockerfile.python | 1 - 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_and_push_ci_image.yml b/.github/workflows/build_and_push_ci_image.yml index 12bb20ca..4f28ba5f 100644 --- a/.github/workflows/build_and_push_ci_image.yml +++ b/.github/workflows/build_and_push_ci_image.yml @@ -48,6 +48,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=104857600 - name: Login to DockerHub uses: docker/login-action@v1 @@ -89,6 +91,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=104857600 - name: Login to DockerHub uses: docker/login-action@v1 @@ -102,7 +106,9 @@ jobs: context: . file: ./tools/docker/ci/Dockerfile.gvisor_test platforms: linux/amd64 - build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }} + build-args: | + "OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}" + "OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}" push: true tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-gvisor_test @@ -118,6 +124,11 @@ jobs: - name: Get occlum version run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV; + - name: Get branch name + # GITHUB_REF=refs/heads/branch-name + # ${GITHUB_REF##*/} == branch-name + run: echo "OCCLUM_BRANCH=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV; + # Because "Build and push" step `context` field can't be subdir, # we need to copy files needed by dockerfile to root dir of the project - name: Copy context for docker build @@ -128,6 +139,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=104857600 - name: Login to DockerHub uses: docker/login-action@v1 @@ -141,7 +154,9 @@ jobs: context: . file: ./tools/docker/ci/Dockerfile.openvino platforms: linux/amd64 - build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }} + build-args: | + "OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}" + "OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}" push: true tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-openvino @@ -157,6 +172,11 @@ jobs: - name: Get occlum version run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV; + - name: Get branch name + # GITHUB_REF=refs/heads/branch-name + # ${GITHUB_REF##*/} == branch-name + run: echo "OCCLUM_BRANCH=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV; + # Because "Build and push" step `context` field can't be subdir, # we need to copy files needed by dockerfile to root dir of the project - name: Copy context for docker build @@ -167,6 +187,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=104857600 - name: Login to DockerHub uses: docker/login-action@v1 @@ -180,7 +202,9 @@ jobs: context: . file: ./tools/docker/ci/Dockerfile.python platforms: linux/amd64 - build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }} + build-args: | + "OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}" + "OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}" push: true tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-python @@ -212,6 +236,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + driver-opts: env.BUILDKIT_STEP_LOG_MAX_SIZE=104857600 - name: Login to DockerHub uses: docker/login-action@v1 diff --git a/tools/docker/ci/Dockerfile.openvino b/tools/docker/ci/Dockerfile.openvino index fa352f1b..f25ea10f 100644 --- a/tools/docker/ci/Dockerfile.openvino +++ b/tools/docker/ci/Dockerfile.openvino @@ -2,9 +2,10 @@ ARG OCCLUM_VERSION FROM occlum/occlum:$OCCLUM_VERSION-ubuntu18.04 as base LABEL maintainer="Chunyang Hui " +ARG OCCLUM_BRANCH WORKDIR /root RUN rm -rf /root/demos && \ - git clone https://github.com/occlum/occlum.git && \ + git clone -b $OCCLUM_BRANCH https://github.com/occlum/occlum.git && \ cp -r occlum/demos /root/demos && \ rm -rf /root/occlum diff --git a/tools/docker/ci/Dockerfile.python b/tools/docker/ci/Dockerfile.python index 91f74a7e..259d8816 100644 --- a/tools/docker/ci/Dockerfile.python +++ b/tools/docker/ci/Dockerfile.python @@ -4,7 +4,6 @@ FROM python:3.7-alpine3.10 as alpine RUN apk add g++ lapack-dev gfortran && \ pip3 install numpy pandas scipy==1.3.1 Cython scikit-learn==0.21.1 - FROM occlum/occlum:$OCCLUM_VERSION-ubuntu18.04 as base LABEL maintainer="Chunyang Hui "