From dc61eab6a1c78dddc59131b75d8d64f52b9aae70 Mon Sep 17 00:00:00 2001 From: Travis Cardwell Date: Sun, 31 Jul 2022 08:33:19 +0900 Subject: [PATCH 1/2] Upgrade Alpine packages (#23) When building an image, the Alpine package index is updated in order to install various dependencies. The versions installed depend on the state of the package index at that time. One therefore does not necessarily get the same packages when building `ghc-musl` images at different times; images are not reproducible in this way. This commit adds a command to upgrade any already-installed packages after the package index is updated. This ensures that the latest packages are used, and that the already-installed packages are consistent with the versions of newly added packages. --- Earthfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Earthfile b/Earthfile index 3a7ae5c..6939142 100644 --- a/Earthfile +++ b/Earthfile @@ -9,6 +9,7 @@ ARG BASE_TAG=utdemir/ghc-musl:v${GHC_MUSL_VERSION}- base-system: FROM alpine:$ALPINE_VERSION RUN apk update \ + && apk upgrade \ && apk add \ autoconf automake bash binutils-gold curl dpkg fakeroot file \ findutils g++ gcc git make perl shadow tar xz \ From 0cb9841e066806a6ee27ff22ce4beab330d8fab3 Mon Sep 17 00:00:00 2001 From: Travis Cardwell Date: Sun, 31 Jul 2022 10:09:28 +0900 Subject: [PATCH 2/2] Change tag and target syntax (#23) Previously, each image was tagged like the following: * `ghc-musl:v24-ghc924` With this commit, each image is now tagged like the following: * `ghc-musl:ghc9.2.4-alpine3.16.1-20220730` * `ghc-musl:ghc9.2.4-alpine3.16.1` * `ghc-musl:ghc9.2.4` This allows users to specify image names according to their needs. An image tagged with the GHC version, Alpine version, and (UTC) build date never changes. An image tagged with just the GHC version and Alpine version may be updated to include minor/security package releases, but the fixed Alpine version means that major upgrades should not break builds. An image tagged with just the GHC version may be updated to include new package releases, both major and minor. The Earthly targets are renamed to match the new tags. For example, previous target `ghc924` is now named `ghc9.2.4`. Note that updating the GHC-only tag should be done with caution, so that it always points to an image using the latest (supported) Alpine version. To facilitate this, the `image` target has a `TAG_GHC` argument that defaults to `0` so that the GHC-only tag is not saved by default. This argument should be set to `1` only when updating the image using the latest (supported) Alpine version. The following command is an example of using this argument when building locally: ``` $ earthly --allow-privileged --build-arg TAG_GHC=1 +ghc9.2.4 ``` The `ALPINE_VERSION` variable is still set to the latest (supported) Alpine version, *not* set to `latest`. Users who would like to use the `latest` image are still able to do so by specifying it in a build argument. --- Earthfile | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/Earthfile b/Earthfile index 6939142..5da77b0 100644 --- a/Earthfile +++ b/Earthfile @@ -3,8 +3,9 @@ VERSION 0.6 ARG ALPINE_VERSION=3.16.1 FROM alpine:$ALPINE_VERSION -ARG GHC_MUSL_VERSION=24 -ARG BASE_TAG=utdemir/ghc-musl:v${GHC_MUSL_VERSION}- +ARG DATE=$(date --utc +%Y%m%d) + +ARG IMAGE_NAME=utdemir/ghc-musl base-system: FROM alpine:$ALPINE_VERSION @@ -78,40 +79,45 @@ image: FROM +ghc ARG TEST_CABAL=1 ARG TEST_STACK=1 - ARG --required TAG + ARG --required GHC + ARG TAG_GHC=0 IF [ "$TEST_CABAL" = "1" ] BUILD +test-cabal END IF [ "$TEST_STACK" = "1" ] BUILD +test-stack END - SAVE IMAGE --push "$TAG" + IF [ "$TAG_GHC" = "1" ] + SAVE IMAGE --push "${IMAGE_NAME}:ghc${GHC}" + END + SAVE IMAGE --push "${IMAGE_NAME}:ghc${GHC}-alpine${ALPINE_VERSION}" + SAVE IMAGE --push "${IMAGE_NAME}:ghc${GHC}-alpine${ALPINE_VERSION}-${DATE}" -ghc924: - BUILD +image --GHC=9.2.4 --TAG=${BASE_TAG}ghc924 +ghc9.2.4: + BUILD +image --GHC=9.2.4 -ghc902: - BUILD +image --GHC=9.0.2 --TAG=${BASE_TAG}ghc902 +ghc9.0.2: + BUILD +image --GHC=9.0.2 -ghc8107: - BUILD +image --GHC=8.10.7 --TAG=${BASE_TAG}ghc8107 +ghc8.10.7: + BUILD +image --GHC=8.10.7 -ghc884: - BUILD +image --GHC=8.8.4 --TAG=${BASE_TAG}ghc884 +ghc8.8.4: + BUILD +image --GHC=8.8.4 readme: RUN apk add bash gettext COPY ./update-readme.sh . RUN ./update-readme.sh \ - "${BASE_TAG}ghc924" \ - "${BASE_TAG}ghc902" \ - "${BASE_TAG}ghc8107" \ - "${BASE_TAG}ghc884" + "${IMAGE_NAME}:ghc9.2.4-alpine${ALPINE_VERSION}-${DATE}" \ + "${IMAGE_NAME}:ghc9.0.2-alpine${ALPINE_VERSION}-${DATE}" \ + "${IMAGE_NAME}:ghc8.10.7-alpine${ALPINE_VERSION}-${DATE}" \ + "${IMAGE_NAME}:ghc8.8.4-alpine${ALPINE_VERSION}-${DATE}" SAVE ARTIFACT README.md all: - BUILD +ghc924 - BUILD +ghc902 - BUILD +ghc8107 - BUILD +ghc884 + BUILD +ghc9.2.4 + BUILD +ghc9.0.2 + BUILD +ghc8.10.7 + BUILD +ghc8.8.4 BUILD +readme