From 52749e1b90fc1df7872e9dcfbc81eb15115e9591 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Tue, 17 Dec 2024 14:05:03 -0500 Subject: [PATCH] try simple, alpine-based, image --- Jenkinsfile | 1344 +++++++++-------- scripts/docker/multiarch/Dockerfile | 70 +- scripts/docker/multiarch_old/Dockerfile | 67 + .../{multiarch => multiarch_old}/README.md | 0 4 files changed, 755 insertions(+), 726 deletions(-) create mode 100644 scripts/docker/multiarch_old/Dockerfile rename scripts/docker/{multiarch => multiarch_old}/README.md (100%) diff --git a/Jenkinsfile b/Jenkinsfile index 28b09ae37..5ab432c91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -104,7 +104,7 @@ pipeline { } options { - parallelsAlwaysFailFast() + // parallelsAlwaysFailFast() buildDiscarder(logRotator(numToKeepStr: '20', daysToKeepStr: '30')) disableConcurrentBuilds(abortPrevious: true) } @@ -209,511 +209,511 @@ pipeline { post { always { runShell("rm -rf ./*") }} } - stage("OCaml tests") { - when { - beforeAgent true - allOf { - expression { - !skipRemainingStages - } - expression { - !params.skip_ocaml_tests - } - } - } - parallel { - stage("Dune tests") { - agent { - dockerfile { - filename 'scripts/docker/debian/Dockerfile' - dir '.' - label 'linux' - args '--entrypoint=\'\'' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/dune-tests"){ - unstash "Stanc3Setup" - runShell(""" - eval \$(opam env) - BISECT_FILE=\$(pwd)/bisect dune runtest --instrument-with bisect_ppx --force --root=. - """) - - sh """ - eval \$(opam env) - bisect-ppx-report summary --expect src/ --do-not-expect src/stancjs/ - bisect-ppx-report coveralls coverage.json --service-name jenkins --service-job-id $BUILD_ID --expect src/ --do-not-expect src/stancjs/ - """ - - withCredentials([usernamePassword(credentialsId: 'stan-stanc3-codecov-token', usernameVariable: 'DUMMY_USERNAME', passwordVariable: 'CODECOV_TOKEN')]) { - sh """ - curl -Os https://uploader.codecov.io/v0.3.2/linux/codecov - - chmod +x codecov - ./codecov -v -C \$(git rev-parse HEAD) - """ - } - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/dune-tests/*") }} - } - stage("stancjs tests") { - agent { - dockerfile { - filename 'scripts/docker/debian/Dockerfile' - dir '.' - label 'linux' - args '--entrypoint=\'\'' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/stancjs-tests"){ - unstash "Stanc3Setup" - runShell(""" - eval \$(opam env) - dune build @runjstest --root=. - """) - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/stancjs-tests/*") }} - } - } - } - - stage("CmdStan & Math tests") { - parallel { - - stage("Compile tests - good") { - when { - beforeAgent true - allOf { - expression { - !skipCompileTests - } - expression { - !params.skip_compile - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-tests-good"){ - unstash "Stanc3Setup" - script { - runPerformanceTests("../test/integration/good", params.stanc_flags) - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-good/*") }} - } - - stage("Compile tests - example-models") { - when { - beforeAgent true - allOf { - expression { - !skipCompileTests - } - expression { - !params.skip_compile - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-tests-example"){ - script { - unstash "Stanc3Setup" - runPerformanceTests("example-models", params.stanc_flags) - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-example/*") }} - } - - stage("Compile tests - good at O=1") { - when { - beforeAgent true - allOf { - expression { - !skipCompileTestsAtO1 - } - expression { - !params.skip_compile_O1 - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-good-O1"){ - unstash "Stanc3Setup" - script { - runPerformanceTests("../test/integration/good", "--O1") - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-good-O1/*") }} - } - - stage("Compile tests - example-models at O=1") { - when { - beforeAgent true - allOf { - expression { - !skipCompileTestsAtO1 - } - expression { - !params.skip_compile_O1 - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-example-O1"){ - script { - unstash "Stanc3Setup" - runPerformanceTests("example-models", "--O1") - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-example-O1/*") }} - } - - stage("Model end-to-end tests") { - when { - beforeAgent true - allOf { - expression { - !skipCompileTests - } - expression { - !params.skip_end_to_end - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-end-to-end"){ - script { - unstash "Stanc3Setup" - unstash 'ubuntu-exe' - sh """ - git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan - """ - utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr) - utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr) - utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr) - sh """ - cd performance-tests-cmdstan - git show HEAD --stat - echo "example-models/regression_tests/mother.stan" > all.tests - cat known_good_perf_all.tests >> all.tests - echo "" >> all.tests - cat shotgun_perf_all.tests >> all.tests - cat all.tests - echo "CXXFLAGS+=-march=core2" > cmdstan/make/local - echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local - cd cmdstan; make clean-all; git show HEAD --stat; cd .. - CXX="${CXX}" ./compare-compilers.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "\$(readlink -f ../bin/stanc)" - """ - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - - archiveArtifacts 'performance-tests-cmdstan/performance.xml' - - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end/*") }} - } - - stage("Model end-to-end tests at O=1") { - when { - beforeAgent true - allOf { - expression { - !params.skip_end_to_end - } - expression { - !skipCompileTestsAtO1 - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-end-to-end-O=1"){ - script { - unstash "Stanc3Setup" - unstash 'ubuntu-exe' - sh """ - git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan - """ - utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr) - utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr) - utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr) - sh """ - cd performance-tests-cmdstan - git show HEAD --stat - echo "example-models/regression_tests/mother.stan" > all.tests - cat optimizer.tests >> all.tests - echo "" >> all.tests - cat known_good_perf_all.tests >> all.tests - echo "" >> all.tests - cat shotgun_perf_all.tests >> all.tests - cat all.tests - echo "CXXFLAGS+=-march=core2" > cmdstan/make/local - echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local - cd cmdstan; make clean-all; git show HEAD --stat; cd .. - CXX="${CXX}" ./compare-optimizer.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "--O1" "\$(readlink -f ../bin/stanc)" - """ - } - - xunit([GoogleTest( - deleteOutputFiles: false, - failIfNotNew: true, - pattern: 'performance-tests-cmdstan/performance.xml', - skipNoTestFiles: false, - stopProcessingIfError: false) - ]) - - archiveArtifacts 'performance-tests-cmdstan/performance.xml' - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end-O=1/*") }} - } - - stage('Math functions expressions test') { - when { - beforeAgent true - allOf { - expression { - !skipRemainingStages - } - expression { - !skipExpressionTests - } - expression { - !params.skip_math_func_expr - } - } - } - agent { - docker { - image 'stanorg/ci:gpu' - label 'linux' - } - } - steps { - dir("${env.WORKSPACE}/compile-expressions"){ - unstash "Stanc3Setup" - unstash 'ubuntu-exe' - script { - sh """ - git clone --recursive https://github.com/stan-dev/math.git - """ - utils.checkout_pr("math", "math", params.math_pr) - sh """ - cp bin/stanc math/test/expressions/stanc - """ - - dir("math") { - sh """ - echo O=0 >> make/local - echo "CXX=${env.CXX} -Werror " >> make/local - """ - withEnv(['PATH+TBB=./lib/tbb']) { - try { sh "./runTests.py -j${env.PARALLEL} test/expressions" } - finally { junit 'test/**/*.xml' } - } - } - } - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/compile-expressions/*") }} - } - } - } - - stage('Build and push multiarch docker image') { - when { - beforeAgent true - expression { - params.build_multiarch_docker_tag != "" - } - } - agent { - dockerfile { - filename 'scripts/docker/builder/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - environment { DOCKER_TOKEN = credentials('aada4f7b-baa9-49cf-ac97-5490620fce8a') } - steps { - script { - retry(3) { checkout scm } - sh ''' - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - docker buildx create --name stanc3_builder - docker buildx use stanc3_builder - - docker login --username stanorg --password "${DOCKER_TOKEN}" - - cd scripts/docker/multiarch - - docker buildx build -t stanorg/stanc3:$build_multiarch_docker_tag \ - --platform linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/mips64le,linux/s390x \ - --build-arg PUID=$(id -u) \ - --build-arg PGID=$(id -g) \ - --progress=plain --push . - ''' - } - } - post { - always { - deleteDir() - } - } - } + // stage("OCaml tests") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipRemainingStages + // } + // expression { + // !params.skip_ocaml_tests + // } + // } + // } + // parallel { + // stage("Dune tests") { + // agent { + // dockerfile { + // filename 'scripts/docker/debian/Dockerfile' + // dir '.' + // label 'linux' + // args '--entrypoint=\'\'' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/dune-tests"){ + // unstash "Stanc3Setup" + // runShell(""" + // eval \$(opam env) + // BISECT_FILE=\$(pwd)/bisect dune runtest --instrument-with bisect_ppx --force --root=. + // """) + + // sh """ + // eval \$(opam env) + // bisect-ppx-report summary --expect src/ --do-not-expect src/stancjs/ + // bisect-ppx-report coveralls coverage.json --service-name jenkins --service-job-id $BUILD_ID --expect src/ --do-not-expect src/stancjs/ + // """ + + // withCredentials([usernamePassword(credentialsId: 'stan-stanc3-codecov-token', usernameVariable: 'DUMMY_USERNAME', passwordVariable: 'CODECOV_TOKEN')]) { + // sh """ + // curl -Os https://uploader.codecov.io/v0.3.2/linux/codecov + + // chmod +x codecov + // ./codecov -v -C \$(git rev-parse HEAD) + // """ + // } + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/dune-tests/*") }} + // } + // stage("stancjs tests") { + // agent { + // dockerfile { + // filename 'scripts/docker/debian/Dockerfile' + // dir '.' + // label 'linux' + // args '--entrypoint=\'\'' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/stancjs-tests"){ + // unstash "Stanc3Setup" + // runShell(""" + // eval \$(opam env) + // dune build @runjstest --root=. + // """) + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/stancjs-tests/*") }} + // } + // } + // } + + // stage("CmdStan & Math tests") { + // parallel { + + // stage("Compile tests - good") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipCompileTests + // } + // expression { + // !params.skip_compile + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-tests-good"){ + // unstash "Stanc3Setup" + // script { + // runPerformanceTests("../test/integration/good", params.stanc_flags) + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-good/*") }} + // } + + // stage("Compile tests - example-models") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipCompileTests + // } + // expression { + // !params.skip_compile + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-tests-example"){ + // script { + // unstash "Stanc3Setup" + // runPerformanceTests("example-models", params.stanc_flags) + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-tests-example/*") }} + // } + + // stage("Compile tests - good at O=1") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipCompileTestsAtO1 + // } + // expression { + // !params.skip_compile_O1 + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-good-O1"){ + // unstash "Stanc3Setup" + // script { + // runPerformanceTests("../test/integration/good", "--O1") + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-good-O1/*") }} + // } + + // stage("Compile tests - example-models at O=1") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipCompileTestsAtO1 + // } + // expression { + // !params.skip_compile_O1 + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-example-O1"){ + // script { + // unstash "Stanc3Setup" + // runPerformanceTests("example-models", "--O1") + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-example-O1/*") }} + // } + + // stage("Model end-to-end tests") { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipCompileTests + // } + // expression { + // !params.skip_end_to_end + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-end-to-end"){ + // script { + // unstash "Stanc3Setup" + // unstash 'ubuntu-exe' + // sh """ + // git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan + // """ + // utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr) + // utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr) + // utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr) + // sh """ + // cd performance-tests-cmdstan + // git show HEAD --stat + // echo "example-models/regression_tests/mother.stan" > all.tests + // cat known_good_perf_all.tests >> all.tests + // echo "" >> all.tests + // cat shotgun_perf_all.tests >> all.tests + // cat all.tests + // echo "CXXFLAGS+=-march=core2" > cmdstan/make/local + // echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local + // cd cmdstan; make clean-all; git show HEAD --stat; cd .. + // CXX="${CXX}" ./compare-compilers.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "\$(readlink -f ../bin/stanc)" + // """ + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + + // archiveArtifacts 'performance-tests-cmdstan/performance.xml' + + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end/*") }} + // } + + // stage("Model end-to-end tests at O=1") { + // when { + // beforeAgent true + // allOf { + // expression { + // !params.skip_end_to_end + // } + // expression { + // !skipCompileTestsAtO1 + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-end-to-end-O=1"){ + // script { + // unstash "Stanc3Setup" + // unstash 'ubuntu-exe' + // sh """ + // git clone --recursive --depth 50 https://github.com/stan-dev/performance-tests-cmdstan + // """ + // utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr) + // utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr) + // utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr) + // sh """ + // cd performance-tests-cmdstan + // git show HEAD --stat + // echo "example-models/regression_tests/mother.stan" > all.tests + // cat optimizer.tests >> all.tests + // echo "" >> all.tests + // cat known_good_perf_all.tests >> all.tests + // echo "" >> all.tests + // cat shotgun_perf_all.tests >> all.tests + // cat all.tests + // echo "CXXFLAGS+=-march=core2" > cmdstan/make/local + // echo "PRECOMPILED_HEADERS=false" >> cmdstan/make/local + // cd cmdstan; make clean-all; git show HEAD --stat; cd .. + // CXX="${CXX}" ./compare-optimizer.sh "--tests-file all.tests --num-samples=10 -j${env.PARALLEL}" "--O1" "\$(readlink -f ../bin/stanc)" + // """ + // } + + // xunit([GoogleTest( + // deleteOutputFiles: false, + // failIfNotNew: true, + // pattern: 'performance-tests-cmdstan/performance.xml', + // skipNoTestFiles: false, + // stopProcessingIfError: false) + // ]) + + // archiveArtifacts 'performance-tests-cmdstan/performance.xml' + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-end-to-end-O=1/*") }} + // } + + // stage('Math functions expressions test') { + // when { + // beforeAgent true + // allOf { + // expression { + // !skipRemainingStages + // } + // expression { + // !skipExpressionTests + // } + // expression { + // !params.skip_math_func_expr + // } + // } + // } + // agent { + // docker { + // image 'stanorg/ci:gpu' + // label 'linux' + // } + // } + // steps { + // dir("${env.WORKSPACE}/compile-expressions"){ + // unstash "Stanc3Setup" + // unstash 'ubuntu-exe' + // script { + // sh """ + // git clone --recursive https://github.com/stan-dev/math.git + // """ + // utils.checkout_pr("math", "math", params.math_pr) + // sh """ + // cp bin/stanc math/test/expressions/stanc + // """ + + // dir("math") { + // sh """ + // echo O=0 >> make/local + // echo "CXX=${env.CXX} -Werror " >> make/local + // """ + // withEnv(['PATH+TBB=./lib/tbb']) { + // try { sh "./runTests.py -j${env.PARALLEL} test/expressions" } + // finally { junit 'test/**/*.xml' } + // } + // } + // } + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/compile-expressions/*") }} + // } + // } + // } + + // stage('Build and push multiarch docker image') { + // when { + // beforeAgent true + // expression { + // params.build_multiarch_docker_tag != "" + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/builder/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // environment { DOCKER_TOKEN = credentials('aada4f7b-baa9-49cf-ac97-5490620fce8a') } + // steps { + // script { + // retry(3) { checkout scm } + // sh ''' + // docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + // docker buildx create --name stanc3_builder + // docker buildx use stanc3_builder + + // docker login --username stanorg --password "${DOCKER_TOKEN}" + + // cd scripts/docker/multiarch + + // docker buildx build -t stanorg/stanc3:$build_multiarch_docker_tag \ + // --platform linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/mips64le,linux/s390x \ + // --build-arg PUID=$(id -u) \ + // --build-arg PGID=$(id -g) \ + // --progress=plain --push . + // ''' + // } + // } + // post { + // always { + // deleteDir() + // } + // } + // } stage('Build binaries') { parallel { - stage("Build & test Mac OS X binary") { - when { - beforeAgent true - expression { !skipRebuildingBinaries } - } - agent { label 'osx && !m1' } - steps { - dir("${env.WORKSPACE}/osx"){ - cleanCheckout() - withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk', 'MACOSX_DEPLOYMENT_TARGET=10.11']) { - runShell(""" - export PATH=/Users/jenkins/brew/bin:\$PATH - eval \$(opam env --switch=stanc-4.14.1 --set-switch) - dune subst - opam update || true - bash -x scripts/install_build_deps.sh - dune build @install --root=. - """) - } - sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-stanc" - stash name:'mac-exe', includes:'bin/*' - } - } - post { always { runShell("rm -rf ${env.WORKSPACE}/osx/*") }} - } - - stage("Build stanc.js") { - when { - beforeAgent true - expression { - !skipRebuildingBinaries - } - } - agent { - dockerfile { - filename 'scripts/docker/debian/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/stancjs"){ - cleanCheckout() - runShell(""" - eval \$(opam env) - dune subst - dune build --root=. --profile release src/stancjs - """) - sh "mkdir -p bin && mv `find _build -name stancjs.bc.js` bin/stanc.js" - sh "mv `find _build -name index.html` bin/load_stanc.html" - runShell(""" - eval \$(opam env) - dune build --force --profile=dev --root=. src/stancjs - """) - sh "mv `find _build -name stancjs.bc.js` bin/stanc-pretty.js" - stash name:'js-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/stancjs/*")}} - } + // stage("Build & test Mac OS X binary") { + // when { + // beforeAgent true + // expression { !skipRebuildingBinaries } + // } + // agent { label 'osx && !m1' } + // steps { + // dir("${env.WORKSPACE}/osx"){ + // cleanCheckout() + // withEnv(['SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.11.sdk', 'MACOSX_DEPLOYMENT_TARGET=10.11']) { + // runShell(""" + // export PATH=/Users/jenkins/brew/bin:\$PATH + // eval \$(opam env --switch=stanc-4.14.1 --set-switch) + // dune subst + // opam update || true + // bash -x scripts/install_build_deps.sh + // dune build @install --root=. + // """) + // } + // sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/mac-stanc" + // stash name:'mac-exe', includes:'bin/*' + // } + // } + // post { always { runShell("rm -rf ${env.WORKSPACE}/osx/*") }} + // } + + // stage("Build stanc.js") { + // when { + // beforeAgent true + // expression { + // !skipRebuildingBinaries + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/debian/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/stancjs"){ + // cleanCheckout() + // runShell(""" + // eval \$(opam env) + // dune subst + // dune build --root=. --profile release src/stancjs + // """) + // sh "mkdir -p bin && mv `find _build -name stancjs.bc.js` bin/stanc.js" + // sh "mv `find _build -name index.html` bin/load_stanc.html" + // runShell(""" + // eval \$(opam env) + // dune build --force --profile=dev --root=. src/stancjs + // """) + // sh "mv `find _build -name stancjs.bc.js` bin/stanc-pretty.js" + // stash name:'js-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/stancjs/*")}} + // } stage("Build & test a static Linux binary") { when { @@ -724,7 +724,7 @@ pipeline { } agent { dockerfile { - filename 'scripts/docker/static/Dockerfile' + filename 'scripts/docker/multiarch/Dockerfile' dir '.' label 'linux && triqs' args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' @@ -746,39 +746,39 @@ pipeline { post {always { runShell("rm -rf ${env.WORKSPACE}/linux/*")}} } - stage("Build & test a static Linux mips64el binary") { - when { - beforeAgent true - allOf { - expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } - } - } - agent { - dockerfile { - filename 'scripts/docker/static/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/linux-mips64el"){ - cleanCheckout() - - sh """ - eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh mips64el ${MULTIARCH_DOCKER_TAG} - """ - - sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-mips64el-stanc" - - stash name:'linux-mips64el-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/linux-mips64el/*")}} - } + // stage("Build & test a static Linux mips64el binary") { + // when { + // beforeAgent true + // allOf { + // expression { !skipRebuildingBinaries } + // anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/static/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/linux-mips64el"){ + // cleanCheckout() + + // sh """ + // eval \$(opam env) + // bash -x scripts/build_multiarch_stanc3.sh mips64el ${MULTIARCH_DOCKER_TAG} + // """ + + // sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-mips64el-stanc" + + // stash name:'linux-mips64el-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/linux-mips64el/*")}} + // } stage("Build & test a static Linux ppc64el binary") { when { @@ -790,20 +790,21 @@ pipeline { } agent { dockerfile { - filename 'scripts/docker/static/Dockerfile' + filename 'scripts/docker/multiarch/Dockerfile' dir '.' label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + args '--platform=linux/ppc64le --group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' + additionalBuildArgs '--platform=linux/ppc64le --build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' } } steps { dir("${env.WORKSPACE}/linux-ppc64el"){ cleanCheckout() - sh """ + runShell(""" eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh ppc64el ${MULTIARCH_DOCKER_TAG} - """ + dune subst + dune build @install --profile static --root=. + """) sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-ppc64el-stanc" stash name:'linux-ppc64el-exe', includes:'bin/*' } @@ -811,36 +812,36 @@ pipeline { post {always { runShell("rm -rf ${env.WORKSPACE}/linux-ppc64el/*")}} } - stage("Build & test a static Linux s390x binary") { - when { - beforeAgent true - allOf { - expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } - } - } - agent { - dockerfile { - filename 'scripts/docker/static/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/linux-s390x"){ - cleanCheckout() - sh """ - eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh s390x ${MULTIARCH_DOCKER_TAG} - """ - sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-s390x-stanc" - stash name:'linux-s390x-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/linux-s390x/*")}} - } + // stage("Build & test a static Linux s390x binary") { + // when { + // beforeAgent true + // allOf { + // expression { !skipRebuildingBinaries } + // anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/static/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/linux-s390x"){ + // cleanCheckout() + // sh """ + // eval \$(opam env) + // bash -x scripts/build_multiarch_stanc3.sh s390x ${MULTIARCH_DOCKER_TAG} + // """ + // sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-s390x-stanc" + // stash name:'linux-s390x-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/linux-s390x/*")}} + // } stage("Build & test a static Linux arm64 binary") { when { @@ -852,20 +853,21 @@ pipeline { } agent { dockerfile { - filename 'scripts/docker/static/Dockerfile' + filename 'scripts/docker/multiarch/Dockerfile' dir '.' label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + args '--platform=linux/arm64 --group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' + additionalBuildArgs '--platform=linux/arm64 --build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' } } steps { dir("${env.WORKSPACE}/linux-arm64"){ cleanCheckout() - sh """ + runShell(""" eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh arm64 ${MULTIARCH_DOCKER_TAG} - """ + dune subst + dune build @install --profile static --root=. + """) sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-arm64-stanc" stash name:'linux-arm64-exe', includes:'bin/*' } @@ -873,99 +875,99 @@ pipeline { post {always { runShell("rm -rf ${env.WORKSPACE}/linux-arm64/*")}} } - stage("Build & test a static Linux armhf binary") { - when { - beforeAgent true - allOf { - expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } - } - } - agent { - dockerfile { - filename 'scripts/docker/static/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/linux-armhf"){ - cleanCheckout() - sh """ - eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh armhf ${MULTIARCH_DOCKER_TAG} - """ - sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armhf-stanc" - stash name:'linux-armhf-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armhf/*")}} - } - - stage("Build & test a static Linux armel binary") { - when { - beforeAgent true - allOf { - expression { !skipRebuildingBinaries } - anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } - } - } - agent { - dockerfile { - filename 'scripts/docker/static/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/linux-armel"){ - cleanCheckout() - sh """ - eval \$(opam env) - bash -x scripts/build_multiarch_stanc3.sh armel ${MULTIARCH_DOCKER_TAG} - """ - sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armel-stanc" - stash name:'linux-armel-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armel/*")}} - } - - // Cross compiling for windows on debian - stage("Build & test static Windows binary") { - when { - beforeAgent true - expression { - !skipRebuildingBinaries - } - } - agent { - dockerfile { - filename 'scripts/docker/debian-windows/Dockerfile' - dir '.' - label 'linux && triqs' - args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' - additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' - } - } - steps { - dir("${env.WORKSPACE}/windows"){ - cleanCheckout() - runShell(""" - eval \$(opam env) - dune subst - dune build -x windows --root=. - """) - sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc" - stash name:'windows-exe', includes:'bin/*' - } - } - post {always { runShell("rm -rf ${env.WORKSPACE}/windows/*")}} - } + // stage("Build & test a static Linux armhf binary") { + // when { + // beforeAgent true + // allOf { + // expression { !skipRebuildingBinaries } + // anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/static/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/linux-armhf"){ + // cleanCheckout() + // sh """ + // eval \$(opam env) + // bash -x scripts/build_multiarch_stanc3.sh armhf ${MULTIARCH_DOCKER_TAG} + // """ + // sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armhf-stanc" + // stash name:'linux-armhf-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armhf/*")}} + // } + + // stage("Build & test a static Linux armel binary") { + // when { + // beforeAgent true + // allOf { + // expression { !skipRebuildingBinaries } + // anyOf { buildingTag(); branch 'master'; expression { params.build_multiarch } } + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/static/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\' -v /var/run/docker.sock:/var/run/docker.sock' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/linux-armel"){ + // cleanCheckout() + // sh """ + // eval \$(opam env) + // bash -x scripts/build_multiarch_stanc3.sh armel ${MULTIARCH_DOCKER_TAG} + // """ + // sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-armel-stanc" + // stash name:'linux-armel-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/linux-armel/*")}} + // } + + // // Cross compiling for windows on debian + // stage("Build & test static Windows binary") { + // when { + // beforeAgent true + // expression { + // !skipRebuildingBinaries + // } + // } + // agent { + // dockerfile { + // filename 'scripts/docker/debian-windows/Dockerfile' + // dir '.' + // label 'linux && triqs' + // args '--group-add=987 --group-add=980 --group-add=988 --entrypoint=\'\'' + // additionalBuildArgs '--build-arg PUID=\$(id -u) --build-arg PGID=\$(id -g)' + // } + // } + // steps { + // dir("${env.WORKSPACE}/windows"){ + // cleanCheckout() + // runShell(""" + // eval \$(opam env) + // dune subst + // dune build -x windows --root=. + // """) + // sh "mkdir -p bin && mv _build/default.windows/src/stanc/stanc.exe bin/windows-stanc" + // stash name:'windows-exe', includes:'bin/*' + // } + // } + // post {always { runShell("rm -rf ${env.WORKSPACE}/windows/*")}} + // } } } diff --git a/scripts/docker/multiarch/Dockerfile b/scripts/docker/multiarch/Dockerfile index ba091e2a9..e2d334d49 100644 --- a/scripts/docker/multiarch/Dockerfile +++ b/scripts/docker/multiarch/Dockerfile @@ -1,67 +1,27 @@ -# Base image -FROM debian:bullseye-20241202 - +FROM alpine:3.21 +LABEL distro_style="apk" +#Switch to root user so we can install apk packages USER root ARG PUID ARG PGID -# Update repositories and install OS deps -RUN apt-get update -RUN apt-get install opam curl bzip2 git tar curl ca-certificates openssl m4 bash -y - -RUN update-ca-certificates -f - -# Setup jenkins uid/gid -RUN addgroup -gid ${PGID} jenkins -RUN adduser --disabled-password --gecos '' --ingroup jenkins --uid ${PUID} jenkins -RUN usermod -a -G sudo jenkins -RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -RUN chown -R jenkins:sudo /usr/local - -WORKDIR /qemu-setup - -# Identify architecture being built for and cache -RUN echo $(dpkg --print-architecture) > ./arch +RUN addgroup -g ${PGID} jenkins && \ + adduser -D -u ${PUID} -G jenkins jenkins -# Translate dpkg architecture naming to QEMU architecture -RUN if [ $(cat ./arch) = "arm64" ]; then \ - QEMU_ARCH="aarch64"; \ - elif [ $(cat ./arch) = "ppc64el" ]; then \ - QEMU_ARCH="ppc64le"; \ - elif [ $(cat ./arch) = "armhf" ]; then \ - QEMU_ARCH="arm"; \ - elif [ $(cat ./arch) = "armel" ]; then \ - QEMU_ARCH="arm"; \ - else \ - QEMU_ARCH=$(cat ./arch); \ - fi && \ - echo $QEMU_ARCH > ./qarch - -# Download needed QEMU binary and place in /usr/bin -RUN curl -L https://github.com/multiarch/qemu-user-static/releases/download/v6.0.0-2/x86_64_qemu-$(cat ./qarch)-static.tar.gz | tar -xzf - -C /usr/bin - -RUN chown jenkins /usr/bin/qemu-$(cat ./qarch)-static +RUN apk update && apk add --no-cache opam build-base bzip2 git tar curl ca-certificates openssl m4 bash +# Switch back to the normal user USER jenkins -WORKDIR /home/jenkins +# Init opam, create and switch to 4.14.0, update shell environment RUN opam init --disable-sandboxing --bare -y -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; \ - else \ - opam switch create 4.14.1 && opam switch 4.14.1; \ - fi +RUN opam switch create 4.14.1 +RUN opam switch 4.14.1 +RUN eval $(opam env) + +COPY ./scripts/install_build_deps.sh ./ +RUN opam update; bash -x install_build_deps.sh -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) && opam install -y cmdliner.1.3.0+dune +RUN opam install odoc -y diff --git a/scripts/docker/multiarch_old/Dockerfile b/scripts/docker/multiarch_old/Dockerfile new file mode 100644 index 000000000..ba091e2a9 --- /dev/null +++ b/scripts/docker/multiarch_old/Dockerfile @@ -0,0 +1,67 @@ +# Base image +FROM debian:bullseye-20241202 + +USER root + +ARG PUID +ARG PGID + +# Update repositories and install OS deps +RUN apt-get update +RUN apt-get install opam curl bzip2 git tar curl ca-certificates openssl m4 bash -y + +RUN update-ca-certificates -f + +# Setup jenkins uid/gid +RUN addgroup -gid ${PGID} jenkins +RUN adduser --disabled-password --gecos '' --ingroup jenkins --uid ${PUID} jenkins +RUN usermod -a -G sudo jenkins +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN chown -R jenkins:sudo /usr/local + +WORKDIR /qemu-setup + +# Identify architecture being built for and cache +RUN echo $(dpkg --print-architecture) > ./arch + +# Translate dpkg architecture naming to QEMU architecture +RUN if [ $(cat ./arch) = "arm64" ]; then \ + QEMU_ARCH="aarch64"; \ + elif [ $(cat ./arch) = "ppc64el" ]; then \ + QEMU_ARCH="ppc64le"; \ + elif [ $(cat ./arch) = "armhf" ]; then \ + QEMU_ARCH="arm"; \ + elif [ $(cat ./arch) = "armel" ]; then \ + QEMU_ARCH="arm"; \ + else \ + QEMU_ARCH=$(cat ./arch); \ + fi && \ + echo $QEMU_ARCH > ./qarch + +# Download needed QEMU binary and place in /usr/bin +RUN curl -L https://github.com/multiarch/qemu-user-static/releases/download/v6.0.0-2/x86_64_qemu-$(cat ./qarch)-static.tar.gz | tar -xzf - -C /usr/bin + +RUN chown jenkins /usr/bin/qemu-$(cat ./qarch)-static + +USER jenkins +WORKDIR /home/jenkins + +RUN opam init --disable-sandboxing --bare -y +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; \ + else \ + opam switch create 4.14.1 && opam switch 4.14.1; \ + fi + +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) && opam install -y cmdliner.1.3.0+dune diff --git a/scripts/docker/multiarch/README.md b/scripts/docker/multiarch_old/README.md similarity index 100% rename from scripts/docker/multiarch/README.md rename to scripts/docker/multiarch_old/README.md