Something went wrong on our end
Select Git revision
.gitlab-ci.yml
-
Christian Winter authoredChristian Winter authored
.gitlab-ci.yml 2.18 KiB
stages:
- 🏗️ build_and_push
- create_jupytermachine_version
variables:
DOCKER_HUB_USER: "jeppelt"
.common_build:
image: docker:latest
stage: 🏗️ build_and_push
rules:
- changes:
- $IMAGE_NAME/Dockerfile
- basis/*
needs: # if the build_and_push step basis has to be done, then make the other build_and_push steps dependend of it
- job: basis
optional: true # only run if basis is added to the pipeline (depends on the rules).
before_script:
- docker login -u "$DOCKER_HUB_USER" -p $DOCKER_TOKEN
script:
- docker build -t "$DOCKER_HUB_USER/etp_$IMAGE_NAME" $IMAGE_NAME/Dockerfile --no-cache;
- docker push "$DOCKER_HUB_USER/etp_$IMAGE_NAME";
basis:
variables:
IMAGE_NAME: "basis"
extends:
- .common_build
tp:
variables:
IMAGE_NAME: "tp"
extends:
- .common_build
python311:
variables:
IMAGE_NAME: "python311"
extends:
- .common_build
basis_jupytermachine:
variables:
IMAGE_NAME: "basis_jupytermachine"
extends:
- .common_build
tp_herwig:
variables:
IMAGE_NAME: "tp_herwig"
extends:
- .common_build
create_jupytermachine_version:
stage: create_jupytermachine_version
image: docker:latest
script:
- |
IMAGES=( "basis" "tp" "python311") # "tp_herwig") # "tp_geant" "cuda_basis"
docker login -u "$DOCKER_HUB_USER" -p $DOCKER_TOKEN
cd basis_jupytermachine
for image in "${IMAGES[@]}"; do
# Read the existing base image from the Dockerfile
OLD_BASE_IMAGE=$(grep -E '^\s*FROM\s+.*' Dockerfile | awk '{print $2}');
echo $OLD_BASE_IMAGE;
# Replace "basic_jupytermachine" with the new base image name
NEW_BASE_IMAGE="$DOCKER_HUB_USER/etp_$image";
echo $NEW_BASE_IMAGE;
sed -i "s#$OLD_BASE_IMAGE#$NEW_BASE_IMAGE#" "Dockerfile"
cat Dockerfile;
# Build the second version of the container
docker build -t "$DOCKER_HUB_USER/jupytermachine_${image}" -f "Dockerfile" . --no-cache;
docker push "$DOCKER_HUB_USER/jupytermachine_${image}";
# Revert the Dockerfile to its original state for other iterations
sed -i "s#$NEW_BASE_IMAGE#$OLD_BASE_IMAGE#" "Dockerfile"
done