Skip to content

Commit cd91323

Browse files
wip
1 parent 92c70b4 commit cd91323

23 files changed

+325
-75
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.jq-template.awk

6.0/alpine/Dockerfile renamed to 6.0/alpine3.18/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM alpine:3.18
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

6.0/Dockerfile renamed to 6.0/bookworm/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM debian:bookworm-slim
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

6.2/alpine/Dockerfile renamed to 6.2/alpine3.18/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM alpine:3.18
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

6.2/Dockerfile renamed to 6.2/bookworm/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM debian:bookworm-slim
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

7.0/alpine/Dockerfile renamed to 7.0/alpine3.18/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM alpine:3.18
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

7.0/Dockerfile renamed to 7.0/bookworm/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM debian:bookworm-slim
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

7.2/alpine/Dockerfile renamed to 7.2/alpine3.18/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM alpine:3.18
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

7.2/Dockerfile renamed to 7.2/bookworm/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#
2+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
3+
#
4+
# PLEASE DO NOT EDIT IT DIRECTLY.
5+
#
6+
17
FROM debian:bookworm-slim
28

39
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
File renamed without changes.

Dockerfile-alpine.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.18
1+
FROM alpine:{{ env.variant | ltrimstr("alpine") }}
22

33
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
44
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 999 redis
@@ -10,9 +10,9 @@ RUN apk add --no-cache \
1010
# add tzdata for https://github.com/docker-library/redis/issues/138
1111
tzdata
1212

13-
ENV REDIS_VERSION placeholder
14-
ENV REDIS_DOWNLOAD_URL placeholder
15-
ENV REDIS_DOWNLOAD_SHA placeholder
13+
ENV REDIS_VERSION {{ .version }}
14+
ENV REDIS_DOWNLOAD_URL {{ .downloadUrl }}
15+
ENV REDIS_DOWNLOAD_SHA {{ .sha256 }}
1616

1717
RUN set -eux; \
1818
\

Dockerfile.template

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM debian:bookworm-slim
1+
FROM debian:{{ env.variant }}-slim
22

33
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
44
RUN groupadd -r -g 999 redis && useradd -r -g redis -u 999 redis
55

66
# grab gosu for easy step-down from root
77
# https://github.com/tianon/gosu/releases
8-
ENV GOSU_VERSION 1.16
8+
ENV GOSU_VERSION {{ .gosu.version }}
99
RUN set -eux; \
1010
savedAptMark="$(apt-mark showmanual)"; \
1111
apt-get update; \
@@ -26,9 +26,9 @@ RUN set -eux; \
2626
gosu --version; \
2727
gosu nobody true
2828

29-
ENV REDIS_VERSION placeholder
30-
ENV REDIS_DOWNLOAD_URL placeholder
31-
ENV REDIS_DOWNLOAD_SHA placeholder
29+
ENV REDIS_VERSION {{ .version }}
30+
ENV REDIS_DOWNLOAD_URL {{ .downloadUrl }}
31+
ENV REDIS_DOWNLOAD_SHA {{ .sha256 }}
3232

3333
RUN set -eux; \
3434
\

apply-templates.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
[ -f versions.json ] # run "versions.sh" first
5+
6+
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
7+
8+
jqt='.jq-template.awk'
9+
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
10+
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
11+
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
12+
# https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk
13+
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk'
14+
fi
15+
16+
jqf='template-helper-functions.jq'
17+
if [ "$BASH_SOURCE" -nt "$jqf" ]; then
18+
wget -qO "$jqf" 'https://github.com/docker-library/bashbrew/raw/master/scripts/template-helper-functions.jq'
19+
fi
20+
21+
if [ "$#" -eq 0 ]; then
22+
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
23+
eval "set -- $versions"
24+
fi
25+
26+
generated_warning() {
27+
cat <<-EOH
28+
#
29+
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
30+
#
31+
# PLEASE DO NOT EDIT IT DIRECTLY.
32+
#
33+
34+
EOH
35+
}
36+
37+
for version; do
38+
export version
39+
40+
if [ -d "$version" ]; then
41+
rm -rf "$version"
42+
fi
43+
44+
if jq -e '.[env.version] | not' versions.json > /dev/null; then
45+
echo "skipping $version ..."
46+
continue
47+
fi
48+
49+
variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)"
50+
eval "variants=( $variants )"
51+
52+
for variant in "${variants[@]}"; do
53+
export variant
54+
55+
echo "processing $version/$variant ..."
56+
57+
dir="$version${variant:+/$variant}"
58+
59+
mkdir -p "$dir"
60+
61+
cp -f docker-entrypoint.sh "$dir/"
62+
63+
case "$variant" in
64+
alpine*)
65+
template='Dockerfile-alpine.template'
66+
sed -i -e 's/gosu/su-exec/g' "$dir/docker-entrypoint.sh"
67+
;;
68+
*)
69+
template='Dockerfile.template'
70+
;;
71+
esac
72+
73+
{
74+
generated_warning
75+
gawk -f "$jqt" "$template"
76+
} > "$dir/Dockerfile"
77+
done
78+
done

update.sh

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,5 @@ set -Eeuo pipefail
33

44
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
55

6-
versions=( "$@" )
7-
if [ ${#versions[@]} -eq 0 ]; then
8-
versions=( */ )
9-
fi
10-
versions=( "${versions[@]%/}" )
11-
12-
packagesUrl='https://raw.githubusercontent.com/redis/redis-hashes/master/README'
13-
packages="$(echo "$packagesUrl" | sed -r 's/[^a-zA-Z.-]+/-/g')"
14-
trap "$(printf 'rm -f %q' "$packages")" EXIT
15-
curl -fsSL "$packagesUrl" -o "$packages"
16-
17-
for version in "${versions[@]}"; do
18-
rcVersion="${version%-rc}"
19-
20-
line="$(
21-
awk '
22-
{ gsub(/^redis-|[.]tar[.]gz$/, "", $2) }
23-
$1 == "hash" && $2 ~ /^'"$rcVersion"'([.]|$)/ { print }
24-
' "$packages" \
25-
| sort -rV \
26-
| head -1
27-
)"
28-
29-
if [ -n "$line" ]; then
30-
fullVersion="$(cut -d' ' -f2 <<<"$line")"
31-
downloadUrl="$(cut -d' ' -f5 <<<"$line")"
32-
shaHash="$(cut -d' ' -f4 <<<"$line")"
33-
shaType="$(cut -d' ' -f3 <<<"$line")"
34-
elif [ "$version" != "$rcVersion" ] && fullVersion="$(
35-
git ls-remote --tags https://github.com/redis/redis.git "refs/tags/$rcVersion*" \
36-
| cut -d/ -f3 \
37-
| cut -d^ -f1 \
38-
| sort -urV \
39-
| head -1
40-
)" && [ -n "$fullVersion" ]; then
41-
downloadUrl="https://github.com/redis/redis/archive/$fullVersion.tar.gz"
42-
shaType='sha256'
43-
shaHash="$(curl -fsSL "$downloadUrl" | "${shaType}sum" | cut -d' ' -f1)"
44-
else
45-
echo >&2 "error: full version for $version cannot be determined"
46-
exit 1
47-
fi
48-
[ "$shaType" = 'sha256' ] || [ "$shaType" = 'sha1' ]
49-
50-
echo "$version: $fullVersion"
51-
52-
for variant in \
53-
alpine '' \
54-
; do
55-
dir="$version${variant:+/$variant}"
56-
[ -d "$dir" ] || continue
57-
template="Dockerfile${variant:+-$variant}.template"
58-
59-
sed -r \
60-
-e 's/^(ENV REDIS_VERSION) .*/\1 '"$fullVersion"'/' \
61-
-e 's!^(ENV REDIS_DOWNLOAD_URL) .*!\1 '"$downloadUrl"'!' \
62-
-e 's/^(ENV REDIS_DOWNLOAD_SHA) .*/\1 '"$shaHash"'/' \
63-
-e 's!sha[0-9]+sum!'"$shaType"'sum!g' \
64-
"$template" > "$dir/Dockerfile"
65-
66-
cp -a docker-entrypoint.sh "$dir/"
67-
if [ "$variant" = 'alpine' ]; then
68-
sed -i -e 's/gosu/su-exec/g' "$dir/docker-entrypoint.sh"
69-
fi
70-
done
71-
done
6+
./versions.sh "$@"
7+
./apply-templates.sh "$@"

versions.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"6.0": {
3+
"alpine": "3.18",
4+
"debian": "bookworm",
5+
"downloadUrl": "http://download.redis.io/releases/redis-6.0.20.tar.gz",
6+
"gosu": {
7+
"version": "1.16"
8+
},
9+
"sha256": "173d4c5f44b5d7186da96c4adc5cb20e8018b50ec3a8dfe0d191dbbab53952f0",
10+
"variants": [
11+
"bookworm",
12+
"alpine3.18"
13+
],
14+
"version": "6.0.20"
15+
},
16+
"6.2": {
17+
"alpine": "3.18",
18+
"debian": "bookworm",
19+
"downloadUrl": "http://download.redis.io/releases/redis-6.2.13.tar.gz",
20+
"gosu": {
21+
"version": "1.16"
22+
},
23+
"sha256": "89ff27c80d420456a721ccfb3beb7cc628d883c53059803513749e13214a23d1",
24+
"variants": [
25+
"bookworm",
26+
"alpine3.18"
27+
],
28+
"version": "6.2.13"
29+
},
30+
"7.0": {
31+
"alpine": "3.18",
32+
"debian": "bookworm",
33+
"downloadUrl": "http://download.redis.io/releases/redis-7.0.13.tar.gz",
34+
"gosu": {
35+
"version": "1.16"
36+
},
37+
"sha256": "97065774d5fb8388eb0d8913458decfcb167d356e40d31dd01cd30c1cc391673",
38+
"variants": [
39+
"bookworm",
40+
"alpine3.18"
41+
],
42+
"version": "7.0.13"
43+
},
44+
"7.2": {
45+
"alpine": "3.18",
46+
"debian": "bookworm",
47+
"downloadUrl": "http://download.redis.io/releases/redis-7.2.1.tar.gz",
48+
"gosu": {
49+
"version": "1.16"
50+
},
51+
"sha256": "5c76d990a1b1c5f949bcd1eed90d0c8a4f70369bdbdcb40288c561ddf88967a4",
52+
"variants": [
53+
"bookworm",
54+
"alpine3.18"
55+
],
56+
"version": "7.2.1"
57+
}
58+
}

0 commit comments

Comments
 (0)