Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ export CUDA_VERSION="12.6.3"
export BASE_IMAGE="nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}"
echo "Building ${IMAGE_NAME} Docker image"

docker build \
# On OSDC the image is built by the out-of-cluster BuildKit pool through a
# remote buildx builder. That builder has nowhere to load an image into, so the
# result has to go straight to the registry.
if [[ -n "${REMOTE_BUILDKIT:-}" ]]; then
BUILD_CMD=(docker buildx build --push)
else
BUILD_CMD=(docker build)
fi

"${BUILD_CMD[@]}" \
--no-cache \
--progress=plain \
-f Dockerfile \
Expand Down
58 changes: 35 additions & 23 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ on:

jobs:
docker-build:
runs-on: [self-hosted, linux.2xlarge]
# BuildKit runs out of cluster on the OSDC BuildKit pool, so this runner only
# streams the (small) .ci/docker context and waits.
runs-on: mt-l-x86iavx512-8-64
container:
image: ghcr.io/actions/actions-runner:latest
timeout-minutes: 240
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
Expand All @@ -25,34 +32,39 @@ jobs:
env:
DOCKER_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/tutorials/${{ matrix.docker-image-name }}
steps:
- name: Clean workspace
shell: bash
run: |
echo "${GITHUB_WORKSPACE}"
sudo rm -rf "${GITHUB_WORKSPACE}"
mkdir "${GITHUB_WORKSPACE}"

- name: Setup SSH (Click me for login details)
uses: pytorch/test-infra/.github/actions/setup-ssh@main
with:
github-secret: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v6

- name: Setup Linux
uses: pytorch/test-infra/.github/actions/setup-linux@main
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::308535385114:role/arc
aws-region: us-east-1
role-duration-seconds: 18000

- name: Build docker image
id: build-docker-image
uses: pytorch/test-infra/.github/actions/calculate-docker-image@main
# buildx forwards the client's registry auth to the remote builder, so the
# push at the end of build.sh authenticates with what this step writes.
- name: Login to ECR
uses: aws-actions/amazon-ecr-login@v2
with:
docker-image-name: ${{ matrix.docker-image-name }}
push: true
registries: "308535385114"

- name: Teardown Linux
uses: pytorch/test-infra/.github/actions/teardown-linux@main
if: always()
- name: Compute the image tag
id: tag
shell: bash
run: |
set -eux
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
DOCKER_TAG=$(git rev-parse HEAD:.ci/docker)
echo "docker-image=${DOCKER_IMAGE}:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"

- name: Build and push to ECR
uses: pytorch/test-infra/.github/actions/docker-build-remote-buildkit@main
with:
command: |
cd .ci/docker
REMOTE_BUILDKIT=1 ./build.sh ${{ matrix.docker-image-name }} \
-t ${{ steps.tag.outputs.docker-image }}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
Expand Down
Loading