Skip to content

Commit

Permalink
Enable nightly expiring container builds
Browse files Browse the repository at this point in the history
* Add optional label to each of the images that allows quay to automatically prune images.
* Add ci step to get the latest release tag
* Set QUAY_IMAGE_TAG to latest release tag + the day of the year
* Set QUAY_EXPIRE to 14 to keep images for 2 weeks initially
* Run publish again where new environment variables should publish expiring images

fixes #8530
https://pulp.plan.io/issues/8530
  • Loading branch information
chambridge committed Apr 9, 2021
1 parent 8a99adc commit e08093a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .ci/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ cd $GITHUB_WORKSPACE/containers/
cp $GITHUB_WORKSPACE/.ci/ansible/vars.yaml vars/vars.yaml
sed -i "s/podman/docker/g" common_tasks.yaml
pip install ansible
ansible-playbook -v build.yaml

if [[ -z "${QUAY_EXPIRE+x}" ]]; then
ansible-playbook -v build.yaml
else
ansible-playbook -v build.yaml --extra-vars "quay_expire=${QUAY_EXPIRE}"
fi
cd $GITHUB_WORKSPACE

echo "Test pulp/pulpcore images"
if [[ -n "${QUAY_EXPIRE}" ]]; then
echo "LABEL quay.expires-after=${QUAY_EXPIRE}d" >> ./build/Dockerfile
fi
sudo -E ./up.sh
.ci/scripts/pulp-operator-check-and-wait.sh $KUBE_FLAG
.ci/scripts/retry.sh 3 ".ci/scripts/pulp_file-tests.sh -m"
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,21 @@ jobs:
git clone --depth=1 https://github.com/pulp/pulp_file.git
.ci/scripts/deploy.sh -m
shell: bash
- id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: draft
- name: Define QUAY_IMAGE_TAG environment variable
run: |
echo "QUAY_IMAGE_TAG=${{steps.latest_release.outputs.release}}-$(date +%j)" >> $GITHUB_ENV
echo "QUAY_EXPIRE=14" >> $GITHUB_ENV
shell: bash
- name: Deploy tagged nightly build
run: |
git clone --depth=1 https://github.com/pulp/pulp_file.git
.ci/scripts/deploy.sh -m
shell: bash
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
1 change: 1 addition & 0 deletions CHANGES/8530.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable additional container builds based on latest tag plus the day of the year along with an expiration
4 changes: 4 additions & 0 deletions containers/images/pulp/Containerfile.core.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM registry.fedoraproject.org/fedora:33

{% if quay_expire is defined %}
LABEL quay.expires-after={{ quay_expire }}d
{% endif %}

# https://superuser.com/questions/959380/how-do-i-install-generate-all-locales-on-fedora
# This may not be necessary anymore because Fedora 30, unlike CentOS 7, has
# glibc subpackages like glibc-langpack-en.
Expand Down
4 changes: 4 additions & 0 deletions containers/images/pulp/Containerfile.web.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ RUN cp -fr /usr/local/lib/python{{ item.value.python_version }}/site-packages/ga

FROM centos/nginx-116-centos7:1.16

{% if quay_expire is defined %}
LABEL quay.expires-after={{ quay_expire }}d
{% endif %}

{% if item.value.base_image_name == "galaxy" %}
COPY --from=builder /www/data .
{% endif %}
Expand Down

0 comments on commit e08093a

Please sign in to comment.