-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Build multiarch image as part of the pipeline, run multiarch build as non-sudoer to fix permissions.
- Loading branch information
1 parent
8bc6ba0
commit e373212
Showing
4 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ pipeline { | |
description: "Math PR to test against. Will check out this PR in the downstream Math repo.") | ||
string(defaultValue: '', name: 'stanc_flags', | ||
description: "Pass STANCFLAGS to make/local, default none") | ||
string(defaultValue: '', name: 'build_multiarch_docker_tag', description: "Docker tag for the multiarch image") | ||
} | ||
options { | ||
parallelsAlwaysFailFast() | ||
|
@@ -100,6 +101,7 @@ pipeline { | |
GIT_AUTHOR_EMAIL = '[email protected]' | ||
GIT_COMMITTER_NAME = 'Stan Jenkins' | ||
GIT_COMMITTER_EMAIL = '[email protected]' | ||
MULTIARCH_DOCKER_TAG = 'multiarch-ocaml-4.14' | ||
} | ||
stages { | ||
stage('Verify changes') { | ||
|
@@ -588,6 +590,51 @@ pipeline { | |
} | ||
} | ||
|
||
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 { | ||
|
@@ -692,17 +739,18 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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 | ||
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" | ||
|
@@ -725,7 +773,7 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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)' | ||
} | ||
|
@@ -735,7 +783,7 @@ pipeline { | |
cleanCheckout() | ||
sh """ | ||
eval \$(opam env) | ||
bash -x scripts/build_multiarch_stanc3.sh ppc64el | ||
bash -x scripts/build_multiarch_stanc3.sh ppc64el ${MULTIARCH_DOCKER_TAG} | ||
""" | ||
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-ppc64el-stanc" | ||
stash name:'linux-ppc64el-exe', includes:'bin/*' | ||
|
@@ -756,7 +804,7 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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)' | ||
} | ||
|
@@ -766,7 +814,7 @@ pipeline { | |
cleanCheckout() | ||
sh """ | ||
eval \$(opam env) | ||
bash -x scripts/build_multiarch_stanc3.sh s390x | ||
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/*' | ||
|
@@ -787,7 +835,7 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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)' | ||
} | ||
|
@@ -797,7 +845,7 @@ pipeline { | |
cleanCheckout() | ||
sh """ | ||
eval \$(opam env) | ||
bash -x scripts/build_multiarch_stanc3.sh arm64 | ||
bash -x scripts/build_multiarch_stanc3.sh arm64 ${MULTIARCH_DOCKER_TAG} | ||
""" | ||
sh "mkdir -p bin && mv `find _build -name stanc.exe` bin/linux-arm64-stanc" | ||
stash name:'linux-arm64-exe', includes:'bin/*' | ||
|
@@ -818,7 +866,7 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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)' | ||
} | ||
|
@@ -828,7 +876,7 @@ pipeline { | |
cleanCheckout() | ||
sh """ | ||
eval \$(opam env) | ||
bash -x scripts/build_multiarch_stanc3.sh armhf | ||
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/*' | ||
|
@@ -849,7 +897,7 @@ pipeline { | |
dockerfile { | ||
filename 'scripts/docker/static/Dockerfile' | ||
dir '.' | ||
label 'linux' | ||
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)' | ||
} | ||
|
@@ -859,7 +907,7 @@ pipeline { | |
cleanCheckout() | ||
sh """ | ||
eval \$(opam env) | ||
bash -x scripts/build_multiarch_stanc3.sh armel | ||
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/*' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Pull the ubuntu:bionic base image | ||
FROM ubuntu:bionic | ||
|
||
USER root | ||
|
||
ARG PUID | ||
ARG PGID | ||
|
||
# Install OS dependencies | ||
RUN apt-get update -qq && apt-get install -y --no-install-recommends \ | ||
curl ca-certificates wget \ | ||
rsync git build-essential m4 unzip pkg-config libpcre3-dev docker \ | ||
python3 python3-pip nodejs sudo | ||
|
||
RUN curl -sSL https://get.docker.com/ | sh | ||
|
||
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 | ||
|
||
USER jenkins | ||
WORKDIR /home/jenkins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters