public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "John Helmert III" <ajak@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/docker-images:master commit in: /
Date: Sun,  3 Mar 2024 04:31:08 +0000 (UTC)	[thread overview]
Message-ID: <1709439766.41303173bdf08e407fb2c39b173efaf6c33051df.ajak@gentoo> (raw)

commit:     41303173bdf08e407fb2c39b173efaf6c33051df
Author:     Rahil Bhimjiani <me <AT> rahil <DOT> rocks>
AuthorDate: Tue Feb 27 16:26:11 2024 +0000
Commit:     John Helmert III <ajak <AT> gentoo <DOT> org>
CommitDate: Sun Mar  3 04:22:46 2024 +0000
URL:        https://gitweb.gentoo.org/proj/docker-images.git/commit/?id=41303173

stage3.Dockerfile: use HEREDOC syntax for RUN command

HEREDOC syntax is supported in docker
https://docs.docker.com/reference/dockerfile/#here-documents

Why:
1) better readability
2) ability to add comments
3) can use HEREDOC in RUN command itself (i.e. configuring
~/.gnupg/dirmngr.conf)
4) by using modern syntax, we can't be labelled as "conservative"[1]

[1] https://github.com/systemd/systemd/pull/31424#issuecomment-1956318843
Signed-off-by: Rahil Bhimjiani <me <AT> rahil.rocks>
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>

 stage3.Dockerfile | 57 +++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 39 insertions(+), 18 deletions(-)

diff --git a/stage3.Dockerfile b/stage3.Dockerfile
index 2aeb250..21235de 100644
--- a/stage3.Dockerfile
+++ b/stage3.Dockerfile
@@ -1,3 +1,7 @@
+# syntax=docker/dockerfile:1
+
+# FIRST LINE IS VERY IMPORTANT. DO NOT MODIFY
+
 # This Dockerfile creates a gentoo stage3 container image. By default it
 # creates a stage3-amd64 image. It utilizes a multi-stage build and requires
 # docker-17.05.0 or later. It fetches a daily snapshot from the official
@@ -14,24 +18,41 @@ ARG SUFFIX
 ARG DIST="https://ftp-osl.osuosl.org/pub/gentoo/releases/${ARCH}/autobuilds"
 ARG SIGNING_KEY="0xBB572E0E2D182910"
 
-RUN echo "Building Gentoo Container image for ${ARCH} ${SUFFIX} fetching from ${DIST}" \
- && apk --no-cache add ca-certificates gnupg tar wget xz \
- && gpg --list-keys \
- && echo "honor-http-proxy" >> ~/.gnupg/dirmngr.conf \
- && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
- && gpg --keyserver hkps://keys.gentoo.org --recv-keys ${SIGNING_KEY} || \
-	gpg --auto-key-locate=clear,nodefault,wkd --locate-key releng@gentoo.org \
- && wget -q "${DIST}/latest-stage3-${MICROARCH}${SUFFIX}.txt" \
- && gpg --verify "latest-stage3-${MICROARCH}${SUFFIX}.txt" \
- && STAGE3PATH="$(sed -n '6p' "latest-stage3-${MICROARCH}${SUFFIX}.txt" | cut -f 1 -d ' ')" \
- && echo "STAGE3PATH:" ${STAGE3PATH} \
- && STAGE3="$(basename ${STAGE3PATH})" \
- && wget -q "${DIST}/${STAGE3PATH}" "${DIST}/${STAGE3PATH}.CONTENTS.gz" "${DIST}/${STAGE3PATH}.asc" \
- && gpg --verify "${STAGE3}.asc" \
- && tar xpf "${STAGE3}" --xattrs-include='*.*' --numeric-owner \
- && ( sed -i -e 's/#rc_sys=""/rc_sys="docker"/g' etc/rc.conf 2>/dev/null || true ) \
- && echo 'UTC' > etc/timezone \
- && rm ${STAGE3}.asc ${STAGE3}.CONTENTS.gz ${STAGE3}
+RUN <<-EOF
+    set -e
+
+    echo "Building Gentoo Container image for ${ARCH} ${SUFFIX} fetching from ${DIST}"
+
+    apk --no-cache add ca-certificates gnupg tar wget xz
+
+    # setup GPG
+    gpg --list-keys
+    # make sure to have <tab> in following heredoc
+    # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
+     cat <<-GPG >> ~/.gnupg/dirmngr.conf
+	honor-http-proxy
+	disable-ipv6
+	GPG
+    gpg --keyserver hkps://keys.gentoo.org --recv-keys ${SIGNING_KEY} || \
+    	gpg --auto-key-locate=clear,nodefault,wkd --locate-key releng@gentoo.org
+
+    # obtain and extract stage3
+    wget -q "${DIST}/latest-stage3-${MICROARCH}${SUFFIX}.txt"
+    gpg --verify "latest-stage3-${MICROARCH}${SUFFIX}.txt"
+    STAGE3PATH="$(sed -n '6p' "latest-stage3-${MICROARCH}${SUFFIX}.txt" | cut -f 1 -d ' ')"
+    echo "STAGE3PATH:" ${STAGE3PATH}
+    STAGE3="$(basename ${STAGE3PATH})"
+    wget -q "${DIST}/${STAGE3PATH}" "${DIST}/${STAGE3PATH}.CONTENTS.gz" "${DIST}/${STAGE3PATH}.asc"
+    gpg --verify "${STAGE3}.asc"
+    tar xpf "${STAGE3}" --xattrs-include='*.*' --numeric-owner
+
+    # modify stage3
+    ( sed -i -e 's/#rc_sys=""/rc_sys="docker"/g' etc/rc.conf 2>/dev/null || true )
+    echo 'UTC' > etc/timezone
+
+    # cleanup
+    rm ${STAGE3}.asc ${STAGE3}.CONTENTS.gz ${STAGE3}
+EOF
 
 FROM scratch
 


             reply	other threads:[~2024-03-03  4:31 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03  4:31 John Helmert III [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-14 21:07 [gentoo-commits] proj/docker-images:master commit in: / John Helmert III
2024-09-08 22:47 John Helmert III
2024-05-26 16:39 John Helmert III
2024-05-26 14:27 John Helmert III
2024-05-26 14:27 John Helmert III
2024-03-03  4:31 John Helmert III
2024-03-03  4:31 John Helmert III
2024-02-18 17:12 John Helmert III
2024-02-08  3:17 John Helmert III
2024-02-08  3:17 John Helmert III
2024-02-08  3:17 John Helmert III
2024-02-08  3:17 John Helmert III
2023-11-26 20:54 John Helmert III
2023-10-14 17:35 John Helmert III
2022-12-21 19:56 John Helmert III
2022-05-23  8:24 Alexys Jacob
2022-02-18 17:39 Alexys Jacob
2021-10-21 11:13 Alexys Jacob
2021-08-30  7:34 Alexys Jacob
2021-04-30  7:58 Alexys Jacob
2021-02-13 17:51 Alexys Jacob
2021-02-13 17:51 Alexys Jacob
2021-02-13 17:51 Alexys Jacob
2021-02-05 21:55 Max Magorsch
2020-09-04 14:49 Alexys Jacob
2020-09-04 14:49 Alexys Jacob
2020-09-03 20:34 Alexys Jacob
2020-08-26  9:03 Alexys Jacob
2020-08-24 13:05 Alexys Jacob
2020-08-24 12:58 Alexys Jacob
2020-08-20 12:17 Alexys Jacob
2020-08-20  9:28 Alexys Jacob
2020-05-26 11:54 Alexys Jacob
2020-04-09  7:26 Alexys Jacob
2020-04-09  7:26 Alexys Jacob
2020-02-23 19:48 Alexys Jacob
2020-02-23 19:46 Alexys Jacob
2020-02-23 19:46 Alexys Jacob
2019-11-15  8:28 Alexys Jacob
2019-11-15  8:28 Alexys Jacob
2019-11-15  8:28 Alexys Jacob
2019-11-15  8:25 Alexys Jacob
2019-11-14 23:02 Alexys Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1709439766.41303173bdf08e407fb2c39b173efaf6c33051df.ajak@gentoo \
    --to=ajak@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox