Add capabilities of building grpc CI image from different branches

This commit is contained in:
Hui, Chunyang 2021-09-26 11:27:20 +00:00 committed by Zongmin.Gu
parent 7dcf727782
commit a0453f1262
2 changed files with 11 additions and 2 deletions

@ -32,11 +32,17 @@ jobs:
- name: Get occlum version - name: Get occlum version
run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV; 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, # 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 # we need to copy files needed by dockerfile to root dir of the project
- name: Copy context for docker build - name: Copy context for docker build
run: | run: |
cp -r tools/docker . cp -r tools/docker .
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
@ -55,7 +61,9 @@ jobs:
context: . context: .
file: ./tools/docker/ci/Dockerfile.grpc file: ./tools/docker/ci/Dockerfile.grpc
platforms: linux/amd64 platforms: linux/amd64
build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }} build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true push: true
tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-grpc tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-grpc

@ -2,9 +2,10 @@ ARG OCCLUM_VERSION
FROM occlum/occlum:$OCCLUM_VERSION-ubuntu18.04 as base FROM occlum/occlum:$OCCLUM_VERSION-ubuntu18.04 as base
LABEL maintainer="Chunyang Hui <sanqian.hcy@antgroup.com>" LABEL maintainer="Chunyang Hui <sanqian.hcy@antgroup.com>"
ARG OCCLUM_BRANCH
WORKDIR /root WORKDIR /root
RUN rm -rf /root/demos && \ 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 && \ cp -r occlum/demos /root/demos && \
rm -rf /root/occlum rm -rf /root/occlum