diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 00000000..147a9a15 --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,67 @@ +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 }} diff --git a/dockerfile/cuda11.1.1.dockerfile b/dockerfile/cuda11.1.1.dockerfile index 5dd089a9..c34a4e58 100644 --- a/dockerfile/cuda11.1.1.dockerfile +++ b/dockerfile/cuda11.1.1.dockerfile @@ -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]