1
0
mirror of https://gitlab.com/jarylc/docker-duoauthproxy.git synced 2026-02-04 13:16:45 +00:00

dynamically select Alpine version with correct Python version pin

This commit is contained in:
Jaryl Chng
2024-10-22 21:45:42 +08:00
parent de19a7b9b9
commit 467a18ecfd
3 changed files with 20 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
ARG PYTHON_VERSION=3.11.9
ARG PYTHON_VERSION
ARG ALPINE_VERSION
FROM python:${PYTHON_VERSION}-alpine3.19 AS builder
FROM python:${PYTHON_VERSION}-alpine${ALPINE_VERSION} AS builder
ARG VERSION
ARG CHECKSUM

View File

@@ -22,7 +22,7 @@ variables:
- name: docker:dind
command: ["--experimental"]
script:
- VERSION=$LATEST CHECKSUM=$CHECKSUM PYTHON_VERSION=$PYTHON_VERSION ./build.sh
- VERSION=$LATEST CHECKSUM=$CHECKSUM PYTHON_VERSION=$PYTHON_VERSION ALPINE_VERSION=$ALPINE_VERSION ./build.sh
build:amd64:
extends: .build-template

View File

@@ -1,28 +1,31 @@
#!/bin/bash
apk add curl jq
apk add curl jq htmlq
[[ ! -f EXISTING ]] || touch EXISTING
EXISTING=$(cat EXISTING)
echo "Existing: ${EXISTING}"
if [[ -n $OVERWRITE ]]; then
echo "Overwriting: $OVERWRITE"
LATEST=$OVERWRITE
else
INFO=$(curl https://duo.com/docs/checksums | grep 'https://dl.duosecurity.com/duoauthproxy' | grep 'src.tgz' | rev | cut -d'>' -f1 | rev)
CHECKSUM=$(echo "$INFO" | cut -d' ' -f1)
LATEST=$(echo "$INFO" | cut -d'-' -f2)
PYTHON_VERSION=$(curl https://duo.com/docs/authproxy-notes | grep -Eo 'Python to \d+\.\d+\.\d+' | head -n1 | rev | cut -d' ' -f1 | rev)
echo "Latest: ${LATEST}"
echo "Checksum: ${CHECKSUM}"
echo "Python Version: ${PYTHON_VERSION}"
fi
INFO=$(curl https://duo.com/docs/checksums | grep 'https://dl.duosecurity.com/duoauthproxy' | grep 'src.tgz' | rev | cut -d'>' -f1 | rev)
CHECKSUM=$(echo "$INFO" | cut -d' ' -f1)
LATEST=$(echo "$INFO" | cut -d'-' -f2)
PYTHON_VERSION=$(curl https://duo.com/docs/authproxy-notes | grep -Eo 'Python to \d+\.\d+\.\d+' | head -n1 | rev | cut -d' ' -f1 | rev)
for ALPINE_VERSION in $(curl -s "https://pkgs.alpinelinux.org/packages?name=python${PYTHON_VERSION%.*.*}" | htmlq -w --text 'select#branch > option' | grep -v 'Branch' | grep -v 'edge' | tac | xargs); do
if curl -s "https://pkgs.alpinelinux.org/packages?name=python${PYTHON_VERSION%.*.*}&branch=${ALPINE_VERSION}" | grep -q ${PYTHON_VERSION%.*}; then
break
fi
done
echo "Latest: ${LATEST}"
echo "Checksum: ${CHECKSUM}"
echo "Python Version: ${PYTHON_VERSION}"
echo "Alpine Version: ${ALPINE_VERSION}"
if [[ (-n "${LATEST}" && "${LATEST}" != "${EXISTING}") ]]; then
mv build.template.yml build.yml
sed -i "s \$CHECKSUM ${CHECKSUM} g" 'build.yml'
sed -i "s \$LATEST ${LATEST} g" 'build.yml'
sed -i "s \$PYTHON_VERSION ${PYTHON_VERSION} g" 'build.yml'
sed -i "s \$ALPINE_VERSION ${ALPINE_VERSION} g" 'build.yml'
echo "Building..."
fi