diff --git a/Jenkinsfile b/Jenkinsfile index 14a6dd6ce..28b09ae37 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -100,6 +100,8 @@ pipeline { description: "Pass STANCFLAGS to make/local, default none") booleanParam(name:"run_slow_perf_tests", defaultValue: false, description:"Run additional 'slow' performance tests") string(defaultValue: '', name: 'build_multiarch_docker_tag', description: "Docker tag for the multiarch image") + booleanParam(name:"build_multiarch", defaultValue: false, description:"Build multiarch images even when not on 'master'") + } options { parallelsAlwaysFailFast() @@ -113,7 +115,7 @@ pipeline { GIT_AUTHOR_EMAIL = 'mc.stanislaw@gmail.com' GIT_COMMITTER_NAME = 'Stan Jenkins' GIT_COMMITTER_EMAIL = 'mc.stanislaw@gmail.com' - MULTIARCH_DOCKER_TAG = 'multiarch-ocaml-4.14-v2' + MULTIARCH_DOCKER_TAG = 'multiarch-ocaml-4.14-v2-and-cmdliner' } stages { stage('Verify changes') { @@ -749,7 +751,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { @@ -783,7 +785,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { @@ -814,7 +816,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { @@ -845,7 +847,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { @@ -876,7 +878,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { @@ -907,7 +909,7 @@ pipeline { beforeAgent true allOf { expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master' } + anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } } } agent { diff --git a/scripts/build_multiarch_stanc3.sh b/scripts/build_multiarch_stanc3.sh index e89b7a3a9..f99e4fabb 100755 --- a/scripts/build_multiarch_stanc3.sh +++ b/scripts/build_multiarch_stanc3.sh @@ -1,21 +1,27 @@ # Architecture naming isn't consistent between QEMU and Docker, so lookup correct naming if [ $1 = "mips64el" ]; then + export DOCK_PLATFORM="linux/mips64le" export DOCK_ARCH="mips64le" export DOCK_VARIANT="" elif [ $1 = "arm64" ]; then + export DOCK_PLATFORM="linux/arm64" export DOCK_ARCH="arm64" export DOCK_VARIANT="" elif [ $1 = "ppc64el" ]; then + export DOCK_PLATFORM="linux/ppc64le" export DOCK_ARCH="ppc64le" export DOCK_VARIANT="" elif [ $1 = "armhf" ]; then + export DOCK_PLATFORM="linux/arm/v7" export DOCK_ARCH="arm" export DOCK_VARIANT="v7" elif [ $1 = "armel" ]; then + export DOCK_PLATFORM="linux/arm/v6" export DOCK_ARCH="arm" export DOCK_VARIANT="v6" elif [ $1 = "s390x" ]; then + export DOCK_PLATFORM="linux/s390x" export DOCK_ARCH="s390x" export DOCK_VARIANT="" fi @@ -26,6 +32,7 @@ DOCKER_IMAGE_TAG="$2" SHA=$(skopeo inspect --raw docker://stanorg/stanc3:${DOCKER_IMAGE_TAG} | jq '.manifests | .[] | select(.platform.architecture==env.DOCK_ARCH and .platform.variant==(if env.DOCK_VARIANT == "" then null else env.DOCK_VARIANT end)).digest' | tr -d '"') # Register QEMU translation binaries -docker run --rm --privileged multiarch/qemu-user-static --reset +docker run --privileged --rm tonistiigi/binfmt --install all -docker run --group-add=987 --group-add=980 --group-add=988 -v $(pwd):$(pwd):rw,z stanorg/stanc3:${DOCKER_IMAGE_TAG}@$SHA /bin/bash -c "cd $(pwd) && eval \$(opam env) && dune subst && dune build @install --profile static --root=." +docker run --platform=${DOCK_PLATFORM} --group-add=987 --group-add=980 --group-add=988 -v $(pwd):$(pwd):rw,z \ + stanorg/stanc3:${DOCKER_IMAGE_TAG}@$SHA /bin/bash -c "cd $(pwd) && eval \$(opam env) && dune subst && dune clean && dune build @install --profile static --root=." diff --git a/scripts/docker/builder/Dockerfile b/scripts/docker/builder/Dockerfile index d094f5f3d..df95f3ba2 100644 --- a/scripts/docker/builder/Dockerfile +++ b/scripts/docker/builder/Dockerfile @@ -1,5 +1,5 @@ -# Pull the ubuntu:bionic base image -FROM ubuntu:bionic +# Pull the ubuntu:jammy base image +FROM ubuntu:jammy USER root @@ -21,4 +21,4 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN chown -R jenkins:sudo /usr/local USER jenkins -WORKDIR /home/jenkins \ No newline at end of file +WORKDIR /home/jenkins diff --git a/scripts/docker/debian-windows/Dockerfile b/scripts/docker/debian-windows/Dockerfile index e2611874e..ef8fe8efd 100644 --- a/scripts/docker/debian-windows/Dockerfile +++ b/scripts/docker/debian-windows/Dockerfile @@ -1,5 +1,5 @@ -#Pull the ubuntu:bionic image -FROM ubuntu:bionic +#Pull the ubuntu:jammy image +FROM ubuntu:jammy USER root @@ -35,13 +35,5 @@ RUN printf "\n" | bash -x install_ocaml.sh "stanc" COPY ./scripts/install_build_deps_windows.sh ./ RUN bash -x install_build_deps_windows.sh -#Copy our script and install dev dependencies -COPY ./scripts/install_dev_deps.sh ./ -RUN bash -x install_dev_deps.sh - -# Install Javascript dev environment -COPY ./scripts/install_js_deps.sh ./ -RUN opam update; bash -x install_js_deps.sh - #Specify our entrypoint ENTRYPOINT [ "opam", "config", "exec", "--" ] diff --git a/scripts/docker/debian/Dockerfile b/scripts/docker/debian/Dockerfile index 36d4c4be8..6b19f2c29 100644 --- a/scripts/docker/debian/Dockerfile +++ b/scripts/docker/debian/Dockerfile @@ -1,5 +1,5 @@ -# Pull the ubuntu:bionic base image -FROM ubuntu:bionic +# Pull the ubuntu:jammy base image +FROM ubuntu:jammy USER root @@ -27,6 +27,7 @@ WORKDIR /home/jenkins #Copy our script and install ocaml + init COPY ./scripts/install_opam.sh ./ RUN printf "\n" | bash -x install_opam.sh +RUN opam update # Install and initialize ocaml COPY ./scripts/install_ocaml.sh ./ @@ -34,15 +35,15 @@ RUN printf "\n" | bash -x install_ocaml.sh "stanc" # Install build dependencies COPY ./scripts/install_build_deps.sh ./ -RUN opam update; bash -x install_build_deps.sh +RUN bash -x install_build_deps.sh # Install dev dependencies COPY ./scripts/install_dev_deps.sh ./ -RUN opam update; bash -x install_dev_deps.sh +RUN bash -x install_dev_deps.sh # Install Javascript dev environment (js_of_ocaml 5.4.0) COPY ./scripts/install_js_deps.sh ./ -RUN opam update; bash -x install_js_deps.sh +RUN bash -x install_js_deps.sh # Specify our entrypoint ENTRYPOINT [ "opam", "config", "exec", "--" ] diff --git a/scripts/docker/multiarch/Dockerfile b/scripts/docker/multiarch/Dockerfile index 22663c3ec..ba091e2a9 100644 --- a/scripts/docker/multiarch/Dockerfile +++ b/scripts/docker/multiarch/Dockerfile @@ -1,5 +1,5 @@ # Base image -FROM debian:buster-20220622-slim +FROM debian:bullseye-20241202 USER root @@ -51,18 +51,17 @@ RUN eval $(opam env) && opam update # Native-code compilation not available on MIPS, fall back to bytecode RUN if [ "$(cat /qemu-setup/arch)" = "mips64el" ]; then \ - opam switch create 4.14.1 --packages=ocaml-variants.4.14.1+options,ocaml-option-bytecode-only && opam switch 4.14.1 && opam pin num https://github.com/ocaml/num.git -y; \ + opam switch create 4.14.1 --packages=ocaml-variants.4.14.1+options,ocaml-option-bytecode-only && opam switch 4.14.1; \ else \ opam switch create 4.14.1 && opam switch 4.14.1; \ fi -RUN eval $(opam env) && opam repo add internet https://opam.ocaml.org - -RUN eval $(opam env) && opam install -y dune +RUN eval $(opam env) && opam repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git RUN eval $(opam env) && opam update && opam upgrade +RUN eval $(opam env) && opam install -y dune RUN eval $(opam env) && opam install -y core.v0.16.0 RUN eval $(opam env) && opam install -y menhir.20230608 RUN eval $(opam env) && opam install -y ppx_deriving.5.2.1 RUN eval $(opam env) && opam install -y fmt.0.9.0 RUN eval $(opam env) && opam install -y yojson.2.1.0 -RUN eval $(opam env) \ No newline at end of file +RUN eval $(opam env) && opam install -y cmdliner.1.3.0+dune diff --git a/scripts/docker/publish/Dockerfile b/scripts/docker/publish/Dockerfile index 3669b50b7..49da70cc6 100644 --- a/scripts/docker/publish/Dockerfile +++ b/scripts/docker/publish/Dockerfile @@ -1,5 +1,5 @@ -# Pull the ubuntu:bionic base image -FROM ubuntu:bionic +# Pull the ubuntu:jammy base image +FROM ubuntu:jammy USER root @@ -25,4 +25,4 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers RUN chown -R jenkins:sudo /usr/local USER jenkins -WORKDIR /home/jenkins \ No newline at end of file +WORKDIR /home/jenkins diff --git a/scripts/docker/static/Dockerfile b/scripts/docker/static/Dockerfile index 920031bd3..ded55e7dd 100644 --- a/scripts/docker/static/Dockerfile +++ b/scripts/docker/static/Dockerfile @@ -28,21 +28,20 @@ RUN CONTAINERS_COMMON_VER=$(curl -s https://dl-cdn.alpinelinux.org/alpine/latest apk add cont.apk && \ apk add skopeo.apk -#Switch back to the normal user +# Switch back to the normal user USER jenkins -#Init opam, create and switch to 4.14.0, update shell environment +# Init opam, create and switch to 4.14.0, update shell environment RUN opam init --disable-sandboxing --bare -y +RUN opam update RUN opam switch create 4.14.0 RUN opam switch 4.14.0 RUN eval $(opam env) -RUN opam repo add internet https://opam.ocaml.org - COPY ./scripts/install_build_deps.sh ./ RUN opam update; bash -x install_build_deps.sh RUN opam install odoc -y -#Specify our entrypoint -ENTRYPOINT [ "opam", "config", "exec", "--" ] \ No newline at end of file +# Specify our entrypoint +ENTRYPOINT [ "opam", "config", "exec", "--" ]