Skip to content

Add initial jq-based templating engine #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

tianon
Copy link
Member

@tianon tianon commented Nov 30, 2021

See also docker-library/php#1052 (and linked PRs).

@tianon
Copy link
Member Author

tianon commented Nov 30, 2021

I generated from master to catch #61, and then generated a library/julia file diff:

Diff:
$ diff -u <(bashbrew cat ./julia) <(bashbrew cat <(./generate-stackbrew-library.sh))
--- /dev/fd/63	2021-11-30 12:52:18.826679248 -0800
+++ /dev/fd/62	2021-11-30 12:52:18.826679248 -0800
@@ -1,114 +1,114 @@
 Maintainers: Tianon Gravi <[email protected]> (@tianon), Joseph Ferguson <[email protected]> (@yosifkit)
 GitRepo: https://github.com/docker-library/julia.git
 
-Tags: 1.7.0-rc3-bullseye, 1.7.0-bullseye, 1.7-bullseye, 1.7-rc-bullseye
-SharedTags: 1.7.0-rc3, 1.7.0, 1.7, 1.7-rc
+Tags: 1.7.0-rc3-bullseye, 1.7-rc-bullseye
+SharedTags: 1.7.0-rc3, 1.7-rc
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: 60d6e4fe76f5884968e589201667b5238a8f9012
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/bullseye
 
-Tags: 1.7.0-rc3-buster, 1.7.0-buster, 1.7-buster, 1.7-rc-buster
+Tags: 1.7.0-rc3-buster, 1.7-rc-buster
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: 2b7266c8907afec471d2434fa49a7daefd9cc5bc
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/buster
 
-Tags: 1.7.0-rc3-alpine3.15, 1.7.0-alpine3.15, 1.7-alpine3.15, 1.7-rc-alpine3.15, 1.7.0-rc3-alpine, 1.7.0-alpine, 1.7-alpine, 1.7-rc-alpine
-GitCommit: 60d6e4fe76f5884968e589201667b5238a8f9012
+Tags: 1.7.0-rc3-alpine3.15, 1.7-rc-alpine3.15, 1.7.0-rc3-alpine, 1.7-rc-alpine
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/alpine3.15
 
-Tags: 1.7.0-rc3-alpine3.14, 1.7.0-alpine3.14, 1.7-alpine3.14, 1.7-rc-alpine3.14
-GitCommit: 2b7266c8907afec471d2434fa49a7daefd9cc5bc
+Tags: 1.7.0-rc3-alpine3.14, 1.7-rc-alpine3.14
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/alpine3.14
 
-Tags: 1.7.0-rc3-windowsservercore-ltsc2022, 1.7.0-windowsservercore-ltsc2022, 1.7-windowsservercore-ltsc2022, 1.7-rc-windowsservercore-ltsc2022
-SharedTags: 1.7.0-rc3, 1.7.0, 1.7, 1.7-rc
+Tags: 1.7.0-rc3-windowsservercore-ltsc2022, 1.7-rc-windowsservercore-ltsc2022
+SharedTags: 1.7.0-rc3, 1.7-rc, 1.7.0-rc3-windowsservercore, 1.7-rc-windowsservercore
 Architectures: windows-amd64
-GitCommit: 2b7266c8907afec471d2434fa49a7daefd9cc5bc
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/windows/windowsservercore-ltsc2022
 Constraints: windowsservercore-ltsc2022
 
-Tags: 1.7.0-rc3-windowsservercore-1809, 1.7.0-windowsservercore-1809, 1.7-windowsservercore-1809, 1.7-rc-windowsservercore-1809
-SharedTags: 1.7.0-rc3, 1.7.0, 1.7, 1.7-rc
+Tags: 1.7.0-rc3-windowsservercore-1809, 1.7-rc-windowsservercore-1809
+SharedTags: 1.7.0-rc3, 1.7-rc, 1.7.0-rc3-windowsservercore, 1.7-rc-windowsservercore
 Architectures: windows-amd64
-GitCommit: 2b7266c8907afec471d2434fa49a7daefd9cc5bc
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/windows/windowsservercore-1809
 Constraints: windowsservercore-1809
 
-Tags: 1.7.0-rc3-windowsservercore-ltsc2016, 1.7.0-windowsservercore-ltsc2016, 1.7-windowsservercore-ltsc2016, 1.7-rc-windowsservercore-ltsc2016
-SharedTags: 1.7.0-rc3, 1.7.0, 1.7, 1.7-rc
+Tags: 1.7.0-rc3-windowsservercore-ltsc2016, 1.7-rc-windowsservercore-ltsc2016
+SharedTags: 1.7.0-rc3, 1.7-rc, 1.7.0-rc3-windowsservercore, 1.7-rc-windowsservercore
 Architectures: windows-amd64
-GitCommit: 2b7266c8907afec471d2434fa49a7daefd9cc5bc
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.7-rc/windows/windowsservercore-ltsc2016
 Constraints: windowsservercore-ltsc2016
 
 Tags: 1.6.4-bullseye, 1.6-bullseye, 1-bullseye, bullseye
 SharedTags: 1.6.4, 1.6, 1, latest
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: 60d6e4fe76f5884968e589201667b5238a8f9012
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/bullseye
 
 Tags: 1.6.4-buster, 1.6-buster, 1-buster, buster
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: ba50b9ecbb663d6eddad95b3ca1a911e273ef950
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/buster
 
 Tags: 1.6.4-alpine3.15, 1.6-alpine3.15, 1-alpine3.15, alpine3.15, 1.6.4-alpine, 1.6-alpine, 1-alpine, alpine
-GitCommit: 60d6e4fe76f5884968e589201667b5238a8f9012
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/alpine3.15
 
 Tags: 1.6.4-alpine3.14, 1.6-alpine3.14, 1-alpine3.14, alpine3.14
-GitCommit: ba50b9ecbb663d6eddad95b3ca1a911e273ef950
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/alpine3.14
 
 Tags: 1.6.4-windowsservercore-ltsc2022, 1.6-windowsservercore-ltsc2022, 1-windowsservercore-ltsc2022, windowsservercore-ltsc2022
-SharedTags: 1.6.4, 1.6, 1, latest
+SharedTags: 1.6.4, 1.6, 1, latest, 1.6.4-windowsservercore, 1.6-windowsservercore, 1-windowsservercore, windowsservercore
 Architectures: windows-amd64
-GitCommit: ba50b9ecbb663d6eddad95b3ca1a911e273ef950
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/windows/windowsservercore-ltsc2022
 Constraints: windowsservercore-ltsc2022
 
 Tags: 1.6.4-windowsservercore-1809, 1.6-windowsservercore-1809, 1-windowsservercore-1809, windowsservercore-1809
-SharedTags: 1.6.4, 1.6, 1, latest
+SharedTags: 1.6.4, 1.6, 1, latest, 1.6.4-windowsservercore, 1.6-windowsservercore, 1-windowsservercore, windowsservercore
 Architectures: windows-amd64
-GitCommit: ba50b9ecbb663d6eddad95b3ca1a911e273ef950
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/windows/windowsservercore-1809
 Constraints: windowsservercore-1809
 
 Tags: 1.6.4-windowsservercore-ltsc2016, 1.6-windowsservercore-ltsc2016, 1-windowsservercore-ltsc2016, windowsservercore-ltsc2016
-SharedTags: 1.6.4, 1.6, 1, latest
+SharedTags: 1.6.4, 1.6, 1, latest, 1.6.4-windowsservercore, 1.6-windowsservercore, 1-windowsservercore, windowsservercore
 Architectures: windows-amd64
-GitCommit: ba50b9ecbb663d6eddad95b3ca1a911e273ef950
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.6/windows/windowsservercore-ltsc2016
 Constraints: windowsservercore-ltsc2016
 
 Tags: 1.0.5-bullseye, 1.0-bullseye
 SharedTags: 1.0.5, 1.0
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: 60d6e4fe76f5884968e589201667b5238a8f9012
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.0/bullseye
 
 Tags: 1.0.5-buster, 1.0-buster
 Architectures: amd64, arm32v7, arm64v8, i386
-GitCommit: 2df03ddf2e51147c7973d4e9fa0bb15602930974
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.0/buster
 
 Tags: 1.0.5-windowsservercore-ltsc2022, 1.0-windowsservercore-ltsc2022
-SharedTags: 1.0.5, 1.0
+SharedTags: 1.0.5, 1.0, 1.0.5-windowsservercore, 1.0-windowsservercore
 Architectures: windows-amd64
-GitCommit: f1b28468460fce290b8d32c20faedafe6c9c041e
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.0/windows/windowsservercore-ltsc2022
 Constraints: windowsservercore-ltsc2022
 
 Tags: 1.0.5-windowsservercore-1809, 1.0-windowsservercore-1809
-SharedTags: 1.0.5, 1.0
+SharedTags: 1.0.5, 1.0, 1.0.5-windowsservercore, 1.0-windowsservercore
 Architectures: windows-amd64
-GitCommit: fc3c116c6fe19f870091df6843ed63a37f6c291b
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.0/windows/windowsservercore-1809
 Constraints: windowsservercore-1809
 
 Tags: 1.0.5-windowsservercore-ltsc2016, 1.0-windowsservercore-ltsc2016
-SharedTags: 1.0.5, 1.0
+SharedTags: 1.0.5, 1.0, 1.0.5-windowsservercore, 1.0-windowsservercore
 Architectures: windows-amd64
-GitCommit: fc3c116c6fe19f870091df6843ed63a37f6c291b
+GitCommit: a120e50c165cedae9526a070a81b3b6c1352cca4
 Directory: 1.0/windows/windowsservercore-ltsc2016
 Constraints: windowsservercore-ltsc2016

@tianon
Copy link
Member Author

tianon commented Nov 30, 2021

The biggest changes (to the tags) in that diff are:

  • adding the (missing) bare windowsservercore aliases
  • removing the 1.7 aliases from the 1.7-rc builds

The second of those is the one I'm less sure about, although it looks like 1.7.0 is just about to drop, so that would make this a moot point until 1.8-rc 😅

@tianon
Copy link
Member Author

tianon commented Nov 30, 2021

With a little git-fu, we can also get a slightly better diff for Dockerfile-debian.template vs Dockerfile-linux.template (that makes it more obvious it's the former with Dockerfile-alpine.template sprinkled in the appropriate places):

Diff:
diff --git a/Dockerfile-debian.template b/Dockerfile-linux.template
similarity index 43%
rename from Dockerfile-debian.template
rename to Dockerfile-linux.template
index 0a69175..48fe90a 100644
--- a/Dockerfile-debian.template
+++ b/Dockerfile-linux.template
@@ -1,4 +1,35 @@
-FROM debian:%%TAG%%
+{{
+	def is_alpine:
+		env.variant | startswith("alpine")
+	;
+	def os_arches:
+		if is_alpine then
+			{
+				amd64: "x86_64",
+				arm32v6: "armhf",
+				arm32v7: "armv7",
+				arm64v8: "aarch64",
+				i386: "x86",
+				ppc64le: "ppc64le",
+				s390x: "s390x",
+			}
+		else
+			{
+				amd64: "amd64",
+				arm32v5: "armel",
+				arm32v7: "armhf",
+				arm64v8: "arm64",
+				i386: "i386",
+				mips64le: "mips64el",
+				ppc64le: "ppc64el",
+				s390x: "s390x",
+			}
+		end
+-}}
+{{ if is_alpine then ( -}}
+FROM alpine:{{ env.variant | ltrimstr("alpine") }}
+{{ ) else ( -}}
+FROM debian:{{ env.variant }}-slim
 
 RUN set -eux; \
 	apt-get update; \
@@ -8,6 +39,7 @@ RUN set -eux; \
 		curl \
 	; \
 	rm -rf /var/lib/apt/lists/*
+{{ ) end -}}
 
 ENV JULIA_PATH /usr/local/julia
 ENV PATH $JULIA_PATH/bin:$PATH
@@ -17,10 +49,13 @@ ENV PATH $JULIA_PATH/bin:$PATH
 ENV JULIA_GPG 3673DF529D9049477F76B37566E3C7DC03D6E495
 
 # https://julialang.org/downloads/
-ENV JULIA_VERSION %%JULIA_VERSION%%
+ENV JULIA_VERSION {{ .version }}
 
 RUN set -eux; \
 	\
+{{ if is_alpine then ( -}}
+	apk add --no-cache --virtual .fetch-deps gnupg; \
+{{ ) else ( -}}
 	savedAptMark="$(apt-mark showmanual)"; \
 	if ! command -v gpg > /dev/null; then \
 		apt-get update; \
@@ -30,17 +65,45 @@ RUN set -eux; \
 		; \
 		rm -rf /var/lib/apt/lists/*; \
 	fi; \
+{{ ) end -}}
 	\
 # https://julialang.org/downloads/#julia-command-line-version
-# https://julialang-s3.julialang.org/bin/checksums/julia-%%JULIA_VERSION%%.sha256
-# this "case" statement is generated via "update.sh"
-	%%ARCH-CASE%%; \
+# https://julialang-s3.julialang.org/bin/checksums/julia-{{ .version }}.sha256
+{{ if is_alpine then ( -}}
+	arch="$(apk --print-arch)"; \
+{{ ) else ( -}}
+	arch="$(dpkg --print-architecture)"; \
+{{ ) end -}}
+	case "$arch" in \
+{{
+	[
+		.arches
+		| to_entries[]
+		| select(.key | if is_alpine then startswith("alpine-") else contains("-") | not end)
+		| (.key | ltrimstr("alpine-")) as $bashbrewArch
+		| (os_arches[$bashbrewArch] // empty) as $osArch
+		| .value
+		| (
+-}}
+		{{ $osArch | @sh }}) \
+			url={{ .url | @sh }}; \
+			sha256={{ .sha256 | @sh }}; \
+			;; \
+{{
+		)
+	] | add
+-}}
+		*) \
+			echo >&2 "error: current architecture ($arch) does not have a corresponding Julia binary release"; \
+			exit 1; \
+			;; \
+	esac; \
 	\
-	folder="$(echo "$JULIA_VERSION" | cut -d. -f1-2)"; \
-	curl -fL -o julia.tar.gz.asc "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${folder}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz.asc"; \
-	curl -fL -o julia.tar.gz     "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${folder}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"; \
+{{ def wget: if is_alpine then "wget -O" else "curl -fL -o" end -}}
+	{{ wget }} julia.tar.gz.asc "$url.asc"; \
+	{{ wget }} julia.tar.gz "$url"; \
 	\
-	echo "${sha256} *julia.tar.gz" | sha256sum -c -; \
+	echo "$sha256 *julia.tar.gz" | sha256sum {{ if is_alpine then "-w -c" else "--strict --check" end }} -; \
 	\
 	export GNUPGHOME="$(mktemp -d)"; \
 	gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$JULIA_GPG"; \
@@ -52,9 +115,13 @@ RUN set -eux; \
 	tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1; \
 	rm julia.tar.gz; \
 	\
+{{ if is_alpine then ( -}}
+	apk del --no-network .fetch-deps; \
+{{ ) else ( -}}
 	apt-mark auto '.*' > /dev/null; \
 	[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
 	apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
+{{ ) end -}}
 	\
 # smoke test
 	julia --version

@yosifkit yosifkit merged commit 3763beb into docker-library:master Dec 1, 2021
@yosifkit yosifkit deleted the jq-template branch December 1, 2021 17:52
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Dec 1, 2021
Changes:

- docker-library/julia@3763beb: Merge pull request docker-library/julia#62 from infosiftr/jq-template
- docker-library/julia@cae8140: Add initial jq-based templating engine
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Dec 2, 2021
Changes:

- docker-library/julia@6e5e202: Merge pull request docker-library/julia#63 from infosiftr/1.7
- docker-library/julia@9c3bc60: Update to 1.7.0 (GA), remove 1.0 (EOL)
- docker-library/julia@3763beb: Merge pull request docker-library/julia#62 from infosiftr/jq-template
- docker-library/julia@cae8140: Add initial jq-based templating engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants