From 9e0f00768bdaff9dd56e0c52d81c05d6dc32883d Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Wed, 15 May 2024 10:46:24 +0200 Subject: [PATCH] [dev] update Docker base images and improve Makefile --- dev/docker/Dockerfile | 13 +++++---- dev/docker/Makefile | 61 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 96e366bce95..dd47fcbe235 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -24,7 +24,8 @@ RUN /init/install.sh \ patch \ tar \ unzip \ - wget + wget \ + which RUN bash -c "yes '' | sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)" --version 2.1.5 @@ -169,8 +170,8 @@ ARG OCAML_VERSION ENV DEBIAN_FRONTEND=noninteractive # Transfers ownership of /home/opam to user opam -# Note: Fedora does not recognize --disabled-password, but it does not need it -RUN adduser --disabled-password opam 2>/dev/null || adduser opam +# Note: Debian and Fedora have 'useradd', but Alpine has 'adduser' +RUN useradd opam || adduser --disabled-password opam COPY --from=frama-c /bin /bin/ COPY --from=frama-c /etc /etc/ @@ -207,7 +208,8 @@ ARG OCAML_VERSION ENV DEBIAN_FRONTEND=noninteractive # Transfers ownership of /home/opam to user opam -RUN adduser --disabled-password opam 2>/dev/null || adduser opam +# Note: Debian and Fedora have 'useradd', but Alpine has 'adduser' +RUN useradd opam || adduser --disabled-password opam COPY --from=frama-c-gui /bin /bin/ COPY --from=frama-c-gui /etc /etc/ @@ -305,7 +307,8 @@ ARG OCAML_VERSION ENV DEBIAN_FRONTEND=noninteractive # Transfers ownership of /home/opam to user opam -RUN adduser --disabled-password opam 2>/dev/null || adduser opam +# Note: Debian and Fedora have 'useradd', but Alpine has 'adduser' +RUN useradd opam || adduser --disabled-password opam COPY --from=frama-c-stripped-prepare /bin /bin/ COPY --from=frama-c-stripped-prepare /etc /etc/ diff --git a/dev/docker/Makefile b/dev/docker/Makefile index 389f8b20743..448e5ec9112 100644 --- a/dev/docker/Makefile +++ b/dev/docker/Makefile @@ -37,26 +37,32 @@ help: echo "- custom.*: version based on a frama-c-*.tar.gz archive (no gui)" echo "- custom-gui.*: same as previous, but with gui" echo "- custom-stripped.*: same as previous, but with minimal size (no gui)" + echo " (custom targets require FRAMAC_ARCHIVE to be set)" echo "" echo "For each target, the suffix (.*) denotes the Docker base image:" - echo "- debian: based on debian:bullseye-slim" + echo "- debian: based on debian:trixie-slim" echo " (default image in the Frama-C Docker Hub)" - echo "- fedora: based on fedora:36" - echo "- alpine: based on alpine:3.16" + echo "- fedora: based on fedora:40" + echo "- alpine: based on alpine:3.19" echo " (smallest image, but E-ACSL does not work due to musl)" echo echo "Targets for users with write access to the framac Docker Hub:" echo "- push TAG=<tag1> AS=<tag2>: perform a docker push with image" echo " <tag1> sent as <tag2>. Usage example:" echo " make push TAG=framac/frama-c:dev.debian AS=framac/frama-c:dev" + echo "" + echo "- dev-push-all: push all variants of dev images" + echo "" + echo "- custom-push-all: push all variants of custom archive images" + echo " (requires FRAMAC_ARCHIVE to be set)" DEPS=../../reference-configuration.md Dockerfile *.sh version=$(shell grep -o "^- OCaml [0-9.]\+" "../../reference-configuration.md" | grep -o "[0-9.]\+") BUILD_ARGS += --build-arg=OCAML_VERSION=$(version) -%.debian: BUILD_ARGS += --build-arg=DISTRO=debian:bookworm-slim -%.fedora: BUILD_ARGS += --build-arg=DISTRO=fedora:39 +%.debian: BUILD_ARGS += --build-arg=DISTRO=debian:trixie-slim +%.fedora: BUILD_ARGS += --build-arg=DISTRO=fedora:40 %.alpine: BUILD_ARGS += --build-arg=DISTRO=alpine:3.19 dev-all: dev.debian dev-stripped.debian dev-gui.debian \ @@ -101,6 +107,7 @@ push: echo " and <new> is the name used in the Docker Hub" echo " e.g. framac/frama-c:dev, framac/frama-c-gui:dev, etc." echo "(if you supplied identical tags, just run 'docker push $(TAG)')" + exit 1 else push: $(DOCKER) tag $(TAG) $(AS) @@ -123,3 +130,47 @@ dev-push-all: $(DOCKER) push framac/frama-c:dev $(DOCKER) push framac/frama-c:dev-stripped $(DOCKER) push framac/frama-c-gui:dev + +ifeq ($(CUSTOM_VERSION),) +custom-push-all: + @echo "error: run '$(MAKE) $@ CUSTOM_VERSION=<version>'" + exit 1 +else +ifeq ($(findstring beta,$(CUSTOM_VERSION)),beta) +custom-push-all: + @echo "error: cannot push a beta archive" + exit 1 +else +custom-push-all: + @echo "Copy and paste the following commands:" + echo "" + echo "$(DOCKER) tag frama-c-custom.debian framac/frama-c:$(CUSTOM_VERSION).debian" + echo "$(DOCKER) tag frama-c-custom-stripped.debian framac/frama-c:$(CUSTOM_VERSION)-stripped.debian" + echo "$(DOCKER) tag frama-c-custom-gui.debian framac/frama-c-gui:$(CUSTOM_VERSION).debian" + echo "" + echo "$(DOCKER) tag frama-c-custom.fedora framac/frama-c:$(CUSTOM_VERSION).fedora" + echo "$(DOCKER) tag frama-c-custom-stripped.fedora framac/frama-c:$(CUSTOM_VERSION)-stripped.fedora" + echo "$(DOCKER) tag frama-c-custom-gui.debian framac/frama-c-gui:$(CUSTOM_VERSION).fedora" + echo "" + echo "$(DOCKER) tag frama-c-custom.alpine framac/frama-c:$(CUSTOM_VERSION).alpine" + echo "$(DOCKER) tag frama-c-custom-stripped.alpine framac/frama-c:$(CUSTOM_VERSION)-stripped.alpine" + echo "$(DOCKER) tag frama-c-custom-gui.alpine framac/frama-c-gui:$(CUSTOM_VERSION).alpine" + echo "" + echo "$(DOCKER) tag framac/frama-c:$(CUSTOM_VERSION).debian framac/frama-c:$(CUSTOM_VERSION)" + echo "$(DOCKER) tag framac/frama-c:$(CUSTOM_VERSION)-stripped.debian framac/frama-c:$(CUSTOM_VERSION)-stripped" + echo "$(DOCKER) tag framac/frama-c-gui:$(CUSTOM_VERSION).debian framac/frama-c-gui:$(CUSTOM_VERSION)" + echo "" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION).debian" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION)-stripped.debian" + echo "$(DOCKER) push framac/frama-c-gui:$(CUSTOM_VERSION).debian" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION).fedora" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION)-stripped.fedora" + echo "$(DOCKER) push framac/frama-c-gui:$(CUSTOM_VERSION).fedora" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION).alpine" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION)-stripped.alpine" + echo "$(DOCKER) push framac/frama-c-gui:$(CUSTOM_VERSION).alpine" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION)" + echo "$(DOCKER) push framac/frama-c:$(CUSTOM_VERSION)-stripped" + echo "$(DOCKER) push framac/frama-c-gui:$(CUSTOM_VERSION)" +endif +endif -- GitLab