Unverified Commit af6eb004 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

CI/CD - Add GitHub Action to build and push image (#70)

* add GitHub Action to build and push image
* update Dockerfile to copy from context
parent 2bc7ada1
name: Build Image
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
docker:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Free disk space
run: |
mkdir /tmp/emptydir
for dir in /usr/share/dotnet /usr/local/lib/android /opt/ghc; do
sudo rsync -a --delete /tmp/emptydir/ ${dir}
done
sudo apt-get clean
df -h
- name: Prepare metadata
id: metadata
run: |
DOCKER_IMAGE=superbench/superbench
IMAGE_TAG=latest
DOCKERFILE=dockerfile/cuda11.1.1.dockerfile
TAGS="${DOCKER_IMAGE}:${IMAGE_TAG}"
CACHE_FROM="type=registry,ref=${DOCKER_IMAGE}:${IMAGE_TAG}"
CACHE_TO=""
if [ "${{ github.event_name }}" = "push" ]; then
CACHE_TO="type=inline"
fi
echo ::set-output name=dockerfile::${DOCKERFILE}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=cache_from::${CACHE_FROM}
echo ::set-output name=cache_to::${CACHE_TO}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
if: ${{ github.event_name == 'push' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
file: ${{ steps.metadata.outputs.dockerfile }}
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.metadata.outputs.tags }}
cache-from: ${{ steps.metadata.outputs.cache_from }}
cache-to: ${{ steps.metadata.outputs.cache_to }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ github.event.repository.pushed_at }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Echo image digest
run: echo ${{ steps.docker_build.outputs.digest }}
......@@ -83,9 +83,8 @@ ENV PATH="${PATH}:/usr/local/cmake/bin:/usr/local/nccl-tests/build" \
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" \
SB_HOME="/opt/superbench"
ARG SB_VERSION="main"
RUN git clone -b ${SB_VERSION} https://github.com/microsoft/superbenchmark ${SB_HOME} && \
cd ${SB_HOME} && \
python3 -m pip install .[torch]
WORKDIR ${SB_HOME}
ADD . .
RUN cd ${SB_HOME} && \
python3 -m pip install .[torch]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment