From cfc129c78456412d44b526a66c107300ad557f76 Mon Sep 17 00:00:00 2001 From: Xu Zhao Date: Thu, 28 Sep 2023 15:41:10 -0400 Subject: [PATCH] Build docker from git ref --- .github/workflows/build-nightly-docker.yml | 6 ++++-- docker/torchbench-nightly.dockerfile | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-nightly-docker.yml b/.github/workflows/build-nightly-docker.yml index 0db45f8695..e1bcf4b29d 100644 --- a/.github/workflows/build-nightly-docker.yml +++ b/.github/workflows/build-nightly-docker.yml @@ -28,8 +28,10 @@ jobs: export TODAY=$(date +'%Y%m%d') export DOCKER_TAG=dev${TODAY} cd benchmark/docker - echo "Github Ref: ${{ github.ref }}" - docker build . --build-arg TORCHBENCH_BRANCH="${{ github.ref }}" -f torchbench-nightly.dockerfile -t ghcr.io/pytorch/torchbench:${DOCKER_TAG} + full_ref="${{ github.ref }}" + prefix="refs/heads/" + branch_name=${full_ref#$prefix} + docker build . --build-arg TORCHBENCH_BRANCH="${branch_name}" -f torchbench-nightly.dockerfile -t ghcr.io/pytorch/torchbench:${DOCKER_TAG} docker tag ghcr.io/pytorch/torchbench:${DOCKER_TAG} ghcr.io/pytorch/torchbench:latest - name: Push docker to remote if: ${{ env.WITH_PUSH == 'true' }} diff --git a/docker/torchbench-nightly.dockerfile b/docker/torchbench-nightly.dockerfile index 063b07a6f6..95ecae4c3e 100644 --- a/docker/torchbench-nightly.dockerfile +++ b/docker/torchbench-nightly.dockerfile @@ -1,14 +1,14 @@ # default base image: xzhao9/gcp-a100-runner-dind:latest ARG BASE_IMAGE=xzhao9/gcp-a100-runner-dind:latest -ARG TORCHBENCH_BRANCH=main FROM ${BASE_IMAGE} ENV CONDA_ENV=torchbench ENV SETUP_SCRIPT=/workspace/setup_instance.sh +ARG TORCHBENCH_BRANCH=${TORCHBENCH_BRANCH:-main} # Setup Conda env and CUDA -RUN git clone -b ${TORCHBENCH_BRANCH} --single-branch \ +RUN git clone -b "${TORCHBENCH_BRANCH}" --single-branch \ https://github.com/pytorch/benchmark /workspace/benchmark RUN cd /workspace/benchmark && \