occlum/.github/workflows/build_and_push_ci_image.yml
2024-03-14 16:23:34 +08:00

316 lines
12 KiB
YAML

name: Build Image for CI (Manual Trigger)
# For some demos which need a lot of dependencies, building and installing
# depencies during every test consumes much time. Thus, build images specific
# for these demos. Now only gRPC OpenVINO and Python need its own test image.
# GVisor syscall test also compiles slow. It needs its own image. The images
# are stored in "occlumbackup/occlum" dockerhub repo.
# This is a manual trigger.
on:
workflow_dispatch:
inputs:
image_name:
description: 'image name (must choose from <grpc, gvisor_test, openvino, python, tf_serving>)'
required: true
default: 'grpc'
reuse_image:
description: 'admin can choose to reuse an old image as the new CI image. set reuse image name, e.g.:0.30.0, 0.30.1-rc'
required: false
jobs:
Build_grpc_image:
runs-on: ubuntu-20.04
if: github.event.inputs.image_name == 'grpc'
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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
run: |
cp -r tools/docker .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Rebuild the image
- name: Build and push
if: "${{ github.event.inputs.reuse_image == '' }}"
uses: docker/build-push-action@v2
with:
context: .
file: ./tools/docker/ci/Dockerfile.grpc
platforms: linux/amd64
build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true
tags: occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-grpc
# Reuse the old image
- name: Reuse the old image
if: "${{ github.event.inputs.reuse_image != '' }}"
run: |
docker pull occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-grpc
docker tag occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-grpc occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-grpc
docker push occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-grpc
Build_gvisor_test_image:
runs-on: ubuntu-20.04
if: github.event.inputs.image_name == 'gvisor_test'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get occlum version
run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $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
run: |
cp -r tools/docker .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Rebuild the image
- name: Build and push
if: "${{ github.event.inputs.reuse_image == '' }}"
uses: docker/build-push-action@v2
with:
context: .
file: ./tools/docker/ci/Dockerfile.gvisor_test
platforms: linux/amd64
build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true
tags: occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-gvisor_test
# Reuse the old image
- name: Reuse the old image
if: "${{ github.event.inputs.reuse_image != '' }}"
run: |
docker pull occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-gvisor_test
docker tag occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-gvisor_test occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-gvisor_test
docker push occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-gvisor_test
Build_openvino_image:
runs-on: ubuntu-20.04
if: github.event.inputs.image_name == 'openvino'
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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
run: |
cp -r tools/docker .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Rebuild the image
- name: Build and push
if: "${{ github.event.inputs.reuse_image == '' }}"
uses: docker/build-push-action@v2
with:
context: .
file: ./tools/docker/ci/Dockerfile.openvino
platforms: linux/amd64
build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true
tags: occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-openvino
# Reuse the old image
- name: Reuse the old image
if: "${{ github.event.inputs.reuse_image != '' }}"
run: |
docker pull occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-openvino
docker tag occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-openvino occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-openvino
docker push occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-openvino
Build_python_image:
runs-on: ubuntu-20.04
if: github.event.inputs.image_name == 'python'
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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
run: |
cp -r tools/docker .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Rebuild the image
- name: Build and push
if: "${{ github.event.inputs.reuse_image == '' }}"
uses: docker/build-push-action@v2
with:
context: .
file: ./tools/docker/ci/Dockerfile.python
platforms: linux/amd64
build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true
tags: occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-python
# Reuse the old image
- name: Reuse the old image
if: "${{ github.event.inputs.reuse_image != '' }}"
run: |
docker pull occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-python
docker tag occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-python occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-python
docker push occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-python
# TODO: Add actions to build tf_serving_base image.
# Building TF serving demo image needs a lot of time which exceeds the maximum time limit for a jong of GitHub Actions.
# Thus dividing into two jobs.
Build_tf_serving_image:
# Building TF serving demo image needs a lot of resources which exceeds the limit of GitHub Actions' hosted machine.
# Thus, we need to build this image on our host machine. This begins from Occlum 0.29.6 and onwards.
runs-on: [self-hosted, SGX2-HW]
if: github.event.inputs.image_name == 'tf_serving'
steps:
- name: Clean before running
run: |
sudo chown -R ${{ secrets.CI_ADMIN }} "${{ github.workspace }}"
- name: Checkout code
uses: actions/checkout@v2
- 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
run: |
cp -r tools/docker .
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Rebuild the image
- name: Build and push
if: "${{ github.event.inputs.reuse_image == '' }}"
uses: docker/build-push-action@v2
with:
context: .
file: ./tools/docker/ci/Dockerfile.tf_serving_occlum
platforms: linux/amd64
build-args: |
"OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}"
"OCCLUM_BRANCH=${{ env.OCCLUM_BRANCH }}"
push: true
tags: occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-tf_serving
# Reuse the old image
- name: Reuse the old image
if: "${{ github.event.inputs.reuse_image != '' }}"
run: |
docker pull occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-tf_serving
docker tag occlumbackup/occlum:${{ github.event.inputs.reuse_image }}-ubuntu20.04-tf_serving occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-tf_serving
docker push occlumbackup/occlum:${{ env.OCCLUM_VERSION }}-ubuntu20.04-tf_serving