Visitar URL original
Use quay.io as a cache for the Docker images · linuxdeploy/linuxdeploy@c11d496 · GitHub
Skip to content

Commit c11d496

Browse files
committed
Use quay.io as a cache for the Docker images
1 parent 0265f2b commit c11d496

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎.github/workflows/main.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,20 @@ jobs:
4848
- name: Set up QEMU integration for Docker
4949
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
5050

51+
# using such an action is more secure than using custom scripts
52+
- name: Log into quay.io
53+
uses: docker/login-action@v3
54+
# secrets are not available when building a pull request
55+
if: ${{ github.event_name != "pull_request" }}
56+
with:
57+
username: ${{ secrets.QUAY_USERNAME }}
58+
password: ${{ secrets.QUAY_PASSPHRASE }}
59+
5160
- name: Build
5261
run: bash ci/build-in-docker.sh
62+
env:
63+
CACHE_FROM: 1
64+
PUSH_IMAGE: ${{ github.event_name == "pull_request" && "1" || "" }}
5365

5466
- name: Archive artifacts
5567
uses: actions/upload-artifact@v2

‎ci/build-in-docker.sh‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,16 @@ else
5757
build_args+=("--pull")
5858
fi
5959

60-
image_tag="linuxdeploy-build:$ARCH"
60+
image_tag="quay.io/theassassin/linuxdeploy-build:$ARCH"
61+
62+
if [[ "${CACHE_FROM:-}" != "" ]]; then
63+
warning "using cached image from quay: $image_tag"
64+
65+
build_args+=(
66+
"--cache-from"
67+
"$image_tag"
68+
)
69+
fi
6170

6271
docker build \
6372
--build-arg ARCH="$ARCH" \
@@ -66,6 +75,12 @@ docker build \
6675
-t "$image_tag" \
6776
"$this_dir"/docker
6877

78+
# by default, we are not logged into the registry and therefore must not attempt to push the image
79+
if [[ "${PUSH_IMAGE:-}" ]]; then
80+
warning "pushing image to quay (requires login): $image_tag"
81+
docker push "$image_tag"
82+
fi
83+
6984
docker_args=()
7085
# only if there's more than 1G of free space in RAM, we can build in a RAM disk
7186
if [[ "${GITHUB_ACTIONS:-}" != "" ]]; then

0 commit comments

Comments
 (0)