Skip to content

Commit

Permalink
Merge pull request #117 from opensafely-core/docker-labels
Browse files Browse the repository at this point in the history
add docker build labels
  • Loading branch information
bloodearnest committed Dec 6, 2022
2 parents c30a953 + c054c20 commit 9c78ae5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion add-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ IMAGE=${IMAGE:-ghcr.io/opensafely-core/r}
# docker tags need to be lowercase
NAME=$(echo "$PACKAGE" | tr '[:upper:]' '[:lower:]')
INSTALL_ARGS="Ncpus=8"
BUILD_DATE="$(date +'%y-%m-%dT%H:%M:%S.%3NZ')"
REVISION="$(git rev-parse --short HEAD)"

trap 'docker container rm $NAME || true' EXIT

Expand All @@ -20,7 +22,7 @@ if test "$TYPE" == "r"; then
else
docker run --name "$NAME" --entrypoint bash "$IMAGE" -c "apt-get install -y $PACKAGE"
fi
docker commit --change "CMD []" --change 'ENTRYPOINT ["/usr/bin/Rscript"]' "$NAME" "r-$NAME"
docker commit --change "CMD []" --change 'ENTRYPOINT ["/usr/bin/Rscript"]' --change "LABEL org.opencontainers.image.created=$BUILD_DATE org.opencontainers.image.revision=$REVISION" "$NAME" "r-$NAME"

if test "$TYPE" == "r"; then
docker run "r-$NAME" -e "library('$PACKAGE')"
Expand Down

0 comments on commit 9c78ae5

Please sign in to comment.