Skip to content

Commit

Permalink
Add service to preload docker images on runner startup
Browse files Browse the repository at this point in the history
  • Loading branch information
GMNGeoffrey authored and Jerry Wu committed Aug 22, 2023
1 parent de5f8bc commit 9e5909d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Copyright 2023 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Pre-fetches docker images so we don't have to wait for docker to fetch them as
# part of `docker run` in the CI jobs. This isn't comprehensive but pre-fetches
# things we think are pretty likely to be useful to pre-fetch. It runs in the
# background so shouldn't have a significant impact on other startup tasks. It
# also won't block fetches being done by the job itself. It could compete for
# network bandwidth though, so we don't want to just always try to fetch
# everything.

set -euo pipefail

source /runner-root/config/functions.sh

nice_curl https://raw.githubusercontent.com/openxla/iree/main/build_tools/docker/prod_digests.txt \
--output /tmp/prod_digests.txt

# Basically everything uses a derivative of one of these
grep 'gcr.io/iree-oss/base@' /tmp/prod_digests.txt | xargs docker pull
grep 'gcr.io/iree-oss/base-bleeding-edge@' /tmp/prod_digests.txt | xargs docker pull

RUNNER_TYPE="$(get_attribute github-runner-type)"

if [[ "${RUNNER_TYPE}" == gpu || "${RUNNER_TYPE}" == a100 ]]; then
grep 'gcr.io/iree-oss/nvidia@' /tmp/prod_digests.txt | xargs docker pull
fi

if [[ "${RUNNER_TYPE}" == a100 ]]; then
grep 'gcr.io/iree-oss/nvidia-bleeding-edge@' /tmp/prod_digests.txt | xargs docker pull
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=GitHub Actions Runner
After=docker.target

[Service]
User=runner
Group=runner
Type=oneshot
EnvironmentFile=/etc/environment
ExecStart=/runner-root/config/systemd/scripts/preload_docker.sh
Restart=no
RemainAfterExit=yes

[Install]
WantedBy=runner-setup.target

0 comments on commit 9e5909d

Please sign in to comment.