Skip to content

Commit f650628

Browse files
committed
update.sh: Bake download URLs directly into Dockerfiles
Signed-off-by: Daniel Rudolf <[email protected]>
1 parent dbfffe5 commit f650628

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Dockerfile-alpine.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ RUN set -ex; \
7070
# Calculate download URL
7171
ENV VERSION %%VERSION%%
7272
ENV SHA256 %%SHA256%%
73-
ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz
73+
ENV URL %%DOWNLOAD_URL%%
7474

7575
LABEL org.opencontainers.image.title="Official phpMyAdmin Docker image" \
7676
org.opencontainers.image.description="Run phpMyAdmin with Alpine, Apache and PHP FPM." \
@@ -90,8 +90,8 @@ RUN set -ex; \
9090
\
9191
export GNUPGHOME="$(mktemp -d)"; \
9292
export GPGKEY="3D06A59ECE730EB71B511C17CE752F178259BD92"; \
93-
curl -fsSL -o phpMyAdmin.tar.xz $URL; \
94-
curl -fsSL -o phpMyAdmin.tar.xz.asc $URL.asc; \
93+
curl -fsSL -o phpMyAdmin.tar.xz "%%DOWNLOAD_URL%%"; \
94+
curl -fsSL -o phpMyAdmin.tar.xz.asc "%%DOWNLOAD_URL_ASC%%"; \
9595
echo "$SHA256 *phpMyAdmin.tar.xz" | sha256sum -c -; \
9696
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$GPGKEY" \
9797
|| gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \

Dockerfile-debian.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ RUN set -ex; \
7272
# Calculate download URL
7373
ENV VERSION %%VERSION%%
7474
ENV SHA256 %%SHA256%%
75-
ENV URL https://files.phpmyadmin.net/phpMyAdmin/${VERSION}/phpMyAdmin-${VERSION}-all-languages.tar.xz
75+
ENV URL %%DOWNLOAD_URL%%
7676

7777
LABEL org.opencontainers.image.title="Official phpMyAdmin Docker image" \
7878
org.opencontainers.image.description="Run phpMyAdmin with Alpine, Apache and PHP FPM." \
@@ -97,8 +97,8 @@ RUN set -ex; \
9797
\
9898
export GNUPGHOME="$(mktemp -d)"; \
9999
export GPGKEY="3D06A59ECE730EB71B511C17CE752F178259BD92"; \
100-
curl -fsSL -o phpMyAdmin.tar.xz $URL; \
101-
curl -fsSL -o phpMyAdmin.tar.xz.asc $URL.asc; \
100+
curl -fsSL -o phpMyAdmin.tar.xz "%%DOWNLOAD_URL%%"; \
101+
curl -fsSL -o phpMyAdmin.tar.xz.asc "%%DOWNLOAD_URL_ASC%%"; \
102102
echo "$SHA256 *phpMyAdmin.tar.xz" | sha256sum -c -; \
103103
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$GPGKEY" \
104104
|| gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \

update.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ declare -A base=(
1919
[fpm-alpine]='alpine'
2020
)
2121

22+
function download_url() {
23+
echo "https://files.phpmyadmin.net/phpMyAdmin/$1/phpMyAdmin-$1-all-languages.tar.xz"
24+
}
25+
2226
function create_variant() {
2327
local variant="$1"
2428
local version="$2"
2529
local sha256="$3"
2630

2731
local branch="$(sed -ne 's/^\([0-9]*\.[0-9]*\)\..*$/\1/p' <<< "$version")"
32+
local url="$(download_url "$version")"
33+
local ascUrl="$(download_url "$version").asc"
2834

2935
echo "updating $version [$branch] $variant"
3036

@@ -35,6 +41,8 @@ function create_variant() {
3541
sed -ri -e '
3642
s/%%VERSION%%/'"$version"'/;
3743
s/%%SHA256%%/'"$sha256"'/;
44+
s/%%DOWNLOAD_URL%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$url")"'/;
45+
s/%%DOWNLOAD_URL_ASC%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$ascUrl")"'/;
3846
s/%%VARIANT%%/'"$variant"'/;
3947
s/%%CMD%%/'"${cmd[$variant]}"'/;
4048
' "$variant/Dockerfile"
@@ -44,7 +52,7 @@ function create_variant() {
4452
}
4553

4654
latest="$(curl -fsSL 'https://www.phpmyadmin.net/home_page/version.json' | jq -r '.version')"
47-
sha256="$(curl -fsSL "https://files.phpmyadmin.net/phpMyAdmin/$latest/phpMyAdmin-$latest-all-languages.tar.xz.sha256" | cut -f1 -d ' ' | tr -cd 'a-f0-9' | cut -c 1-64)"
55+
sha256="$(curl -fsSL "$(download_url "$latest").sha256" | cut -f1 -d ' ' | tr -cd 'a-f0-9' | cut -c 1-64)"
4856

4957
for variant in apache fpm fpm-alpine; do
5058
create_variant "$variant" "$latest" "$sha256"

0 commit comments

Comments
 (0)