Skip to content

Commit

Permalink
chore: dismiss Debian images and archive Ironbank
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei committed Oct 31, 2023
1 parent f39c1c4 commit 87080e9
Show file tree
Hide file tree
Showing 33 changed files with 15 additions and 7,463 deletions.
124 changes: 0 additions & 124 deletions .github/generate-strategy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
#

set -eu
declare BUILD_IRONBANK=false
# Want to get the IronBank during the Continuous Integration step
# but not during the Continuous Delivery step.
while getopts "i" option; do
case $option in
i)
BUILD_IRONBANK=true
;;
esac
done

# Define an optional aliases for some major versions
declare -A aliases=(
Expand All @@ -37,28 +27,8 @@ for version in */; do
done
ubi_versions=("${ubi_versions[@]%/}")

# Retrieve the PostgreSQL versions for Debian
cd "$BASE_DIRECTORY"/Debian/
for version in */; do
[[ $version == src/ ]] && continue
debian_versions+=("$version")
done
debian_versions=("${debian_versions[@]%/}")

# Retrieve the PostgreSQL versions for IronBank
cd "$BASE_DIRECTORY"/IronBank/
for version in $(find -maxdepth 1 -type d -regex "^./[0-9].*" | sort -n) ; do
ironbank_versions+=("$version")
done
#trim the beginning slash
ironbank_versions=("${ironbank_versions[@]#./}")
#trim the ending slash
ironbank_versions=("${ironbank_versions[@]%/}")

# Sort the version numbers with highest first
mapfile -t ubi_versions < <(IFS=$'\n'; sort -rV <<< "${ubi_versions[*]}")
mapfile -t debian_versions < <(IFS=$'\n'; sort -rV <<< "${debian_versions[*]}")
mapfile -t ironbank_versions < <(IFS=$'\n'; sort -rV <<< "${ironbank_versions[*]}")

# prints "$2$1$3$1...$N"
join() {
Expand Down Expand Up @@ -191,100 +161,6 @@ for version in "${ubi_versions[@]}"; do
)
done

# IronBank
cd "$BASE_DIRECTORY"/IronBank/
for version in "${ironbank_versions[@]}"; do

# Read versions from the definition file
versionFile="${version}/.versions.json"
fullVersion=$(jq -r '.POSTGRES_VERSION | split("-") | .[0]' "${versionFile}")
releaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")

# Initial aliases are "major version", "optional alias", "full version with release"
# i.e. "13", "latest", "13.2-1"
# A "-beta" suffix will be appended to the beta images.
if [ "${version}" -gt '15' ]; then
fullVersion=$(jq -r '.POSTGRES_VERSION | split("_") | .[0]' "${versionFile}")
versionAliases=(
"${version}-beta"
${aliases[$version]:+"${aliases[$version]}"}
"${fullVersion}-${releaseVersion}"
)
else
versionAliases=(
"${version}"
${aliases[$version]:+"${aliases[$version]}"}
"${fullVersion}"-"${releaseVersion}"
)
fi
# Add all the version prefixes between full version and major version
# i.e "13.2"
while [ "$fullVersion" != "$version" ] && [ "${fullVersion%[.-]*}" != "$fullVersion" ]; do
versionAliases+=("$fullVersion")
fullVersion="${fullVersion%[.-]*}"
done

# Only
platforms="linux/amd64"
IB_BASE_REGISTRY="registry.access.redhat.com"
IB_BASE_IMAGE="ubi8"

# Build the json entry
if [[ "$BUILD_IRONBANK" == "true" ]]; then
entries+=(
"{ \"name\": \"IronBank ${fullVersion}\",
\"platforms\": \"$platforms\",
\"dir\": \"IronBank/$version\",
\"file\": \"IronBank/$version/Dockerfile\",
\"version\": \"$version\",
\"tags\": [\"$(join "\", \"" "${versionAliases[@]}")\"],
\"build_args\": {\"BASE_REGISTRY\": \"${IB_BASE_REGISTRY}\", \"BASE_IMAGE\": \"${IB_BASE_IMAGE}\"}
}" )
fi
done

# Debian
cd "$BASE_DIRECTORY"/Debian/
for version in "${debian_versions[@]}"; do

# Read versions from the definition file
versionFile="${version}/.versions.json"
fullVersion=$(jq -r '.POSTGRES_VERSION | split("-") | .[0]' "${versionFile}")
releaseVersion=$(jq -r '.IMAGE_RELEASE_VERSION' "${versionFile}")

# Initial aliases are "major version", "optional alias", "full version with release"
# i.e. "13", "latest", "13.2-1"
# A "-beta" suffix will be appended to the beta images.
if [ "${version}" -gt '16' ]; then
fullVersion="${fullVersion//'~'/-}"
versionAliases=(
"${version}-beta-debian"
${aliases[$version]:+"${aliases[$version]}-debian"}
"${fullVersion}-debian-${releaseVersion}"
)
else
versionAliases=(
"${version}-debian"
${aliases[$version]:+"${aliases[$version]}-debian"}
"${fullVersion}-debian-${releaseVersion}"
)
fi

# Add all the version prefixes between full version and major version
# i.e "13.2"
while [ "$fullVersion" != "$version" ] && [ "${fullVersion%[.-]*}" != "$fullVersion" ]; do
versionAliases+=("$fullVersion-debian")
fullVersion="${fullVersion%[.-]*}"
done

platforms="linux/amd64,linux/arm64"

# Build the json entry
entries+=(
"{\"name\": \"Debian ${fullVersion}\", \"platforms\": \"$platforms\", \"dir\": \"Debian/$version\", \"file\": \"Debian/$version/Dockerfile\", \"version\": \"$version\", \"tags\": [\"$(join "\", \"" "${versionAliases[@]}")\"]}"
)
done

# Build the strategy as a JSON object
strategy="{\"fail-fast\": false, \"matrix\": {\"include\": [$(join ', ' "${entries[@]}")]}}"
jq -C . <<<"$strategy" # sanity check / debugging aid
Expand Down
27 changes: 2 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v4
- id: generate-jobs
name: Generate Jobs
run: .github/generate-strategy.sh -i
run: .github/generate-strategy.sh

test:
needs: generate-jobs
Expand All @@ -33,10 +33,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Prepare Environment
run: |
git clone --depth 1 https://github.com/docker-library/official-images.git -b master ~/oi
Expand All @@ -49,31 +45,13 @@ jobs:
- name: Docker meta
env:
BUILD_ARGS: ${{ toJson(matrix.build_args) }}
TAGS: ${{ toJson(matrix.tags) }}
run: |
ARGS=""
# Only Ironbank builds use build-args. We get here the packages
# required in the case
if [[ "${BUILD_ARGS}" != "null" ]]; then
ARGS+=$(echo "${BUILD_ARGS}" | jq -r '. | "BASE_REGISTRY=\(.BASE_REGISTRY)\nBASE_IMAGE=\(.BASE_IMAGE)"')
for u in $(cat "${{ matrix.dir }}/urls.txt")
do curl -fsSL -o "${{ matrix.dir}}"/$(basename $u) $u
done
python3 -m pip install --upgrade pip
python3 -m pip download -r "${{ matrix.dir }}/requirements.txt" -d "${{ matrix.dir }}"
fi
RESULT=""
for tag in $(jq -r '.[]' <<< "${TAGS}")
do
RESULT="${RESULT},${IMAGE_NAME}:${tag}"
done
# Handling multiline GitHub Env
echo "BUILD-ARGS<<EOF" >> $GITHUB_ENV
echo "$ARGS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "TAGS=${RESULT%,}" >> $GITHUB_ENV
- name: Build ${{ matrix.name }}
Expand All @@ -89,8 +67,7 @@ jobs:
tags: ${{ env.TAGS }}
load: true
build-args: |
SUBSCRIPTION_NAME=docker-postgresql-cicd-${{ github.run_number }}
${{ env.BUILD-ARGS }}
SUBSCRIPTION_NAME=docker-postgresql-ci-${{ github.run_number }}
- name: History ${{ matrix.name }}
run: docker history "${IMAGE_NAME}:${{ matrix.tags[0] }}"
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,21 @@ jobs:
timeout_seconds: 20
max_attempts: 3
command: |
echo "Updating Debian docker-entrypoint"
curl -fsSo ./Debian/src/root/usr/local/bin/docker-entrypoint.sh https://raw.githubusercontent.com/docker-library/postgres/master/docker-entrypoint.sh
echo "Updating UBI docker-entrypoint"
cp ./Debian/src/root/usr/local/bin/docker-entrypoint.sh ./UBI/src/root/usr/local/bin/docker-entrypoint.sh
cp ./Debian/src/root/usr/local/bin/docker-entrypoint.sh ./IronBank/src/root/scripts/docker-entrypoint.sh
curl -fsSo ./UBI/src/root/usr/local/bin/docker-entrypoint.sh https://raw.githubusercontent.com/docker-library/postgres/master/docker-entrypoint.sh
- name: Run update script
uses: nick-fields/retry@v2
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
BASE_REGISTRY: "registry.access.redhat.com"
BASE_IMAGE: "ubi8"
with:
timeout_minutes: 15
max_attempts: 3
command: |
# pip-tools provides pip-compile used by update.sh
export PATH=$HOME/.local/bin:$PATH
pip3 install --upgrade pip-tools cloudsmith-cli pip pyyaml
pip3 install --upgrade pip-tools cloudsmith-cli pip
echo "Updating UBI images"
./UBI/update.sh
echo "Updating Debian images"
./Debian/update.sh
echo "Updating IronBank images"
./IronBank/update.sh
- name: Diff
run: |
git status
Expand Down
6 changes: 0 additions & 6 deletions Debian/11/.versions.json

This file was deleted.

Loading

0 comments on commit 87080e9

Please sign in to comment.