diff options
Diffstat (limited to 'salt/gentoo_baseimage/ci/files/build.sh')
| -rw-r--r-- | salt/gentoo_baseimage/ci/files/build.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/salt/gentoo_baseimage/ci/files/build.sh b/salt/gentoo_baseimage/ci/files/build.sh new file mode 100644 index 0000000..b42f01b --- /dev/null +++ b/salt/gentoo_baseimage/ci/files/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash -e + +mark_for_gc() { + image_name="${1}" + for tag in $(curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' https://{{ pillar["registry"]["url"] }}/v2/${image_name}/tags/list | jq '.tags' | grep -o -P '[a-fA-F0-9]+'); do + digest=$(curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' https://{{ pillar["registry"]["url"] }}/v2/${image_name}/manifests/${tag} | jq '.config.digest' | awk -F\" '{print $2}') + if [ "${digest}" != "" ]; then + curl -u '{{ pillar["registry"]["username"] }}:{{ pillar["registry"]["password"] }}' -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' -X DELETE https://{{ pillar["registry"]["url"] }}/v2/${image_name}/manifests/${digest} + fi + done +} + +{% if pillar["ci"]["local_build"] != True %} +echo "Login to docker registry" +echo '{{ pillar["registry"]["password"] }}' | docker login --username {{ pillar["registry"]["username"] }} --password-stdin {{ pillar["registry"]["url"] }} +{% endif %} + +{% if pillar["ci"]["local_build"] != True %} +mark_for_gc "{{ pillar["gentoo_baseimage"]["image_name"] }}" +{% endif %} +{{ pillar["gentoo_baseimage"]["build_dir"] }}/build.sh + +exit 0 |
