Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
course-container
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EnJoY
course-container
Commits
fc701ca6
Commit
fc701ca6
authored
1 year ago
by
Christian Winter
Browse files
Options
Downloads
Patches
Plain Diff
create pipeline steps for each container, that only execute if the relevant Dockerfile was changed
parent
6d7862b7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+45
-20
45 additions, 20 deletions
.gitlab-ci.yml
with
45 additions
and
20 deletions
.gitlab-ci.yml
+
45
−
20
View file @
fc701ca6
stages
:
stages
:
-
build_and_push
-
🏗️
build_and_push
-
create_jupytermachine_version
-
create_jupytermachine_version
variables
:
variables
:
DOCKER_REGISTRY
:
"
docker.io"
DOCKER_HUB_USER
:
"
jeppelt"
IMAGE_PREFIX
:
"
jeppelt"
# Change this to your Docker Hub username
JUPYTERMACHINE_DOCKERFILE
:
"
basic_jupytermachine/Dockerfile"
build_and_push
:
.common_build
:
stage
:
build_and_push
image
:
docker:latest
image
:
docker:latest
stage
:
🏗️ build_and_push
rules
:
-
changes
:
-
$IMAGE_NAME/Dockerfile
before_script
:
-
docker login -u $DOCKER_HUB_USER -p $DOCKER_TOKEN
script
:
script
:
-
|
-
docker build -t "$DOCKER_HUB_USER/etp_$IMAGE_NAME" $IMAGE_NAME/Dockerfile --no-cache;
export IMAGES=( "basis" "tp" "python311" "basis_jupytermachine") # "tp_herwig") # "tp_geant" "cuda_basis"
-
docker push "$DOCKER_HUB_USER/etp_$IMAGE_NAME";
docker login -u jeppelt -p $DOCKER_TOKEN;
for image in "${IMAGES[@]}"; do
basis
:
echo "$image";
variables
:
cd "$image";
IMAGE_NAME
:
"
basis"
docker build -t "$IMAGE_PREFIX/etp_${image}" . --no-cache;
extends
:
docker push "$IMAGE_PREFIX/etp_${image}";
-
.common_build
cd ../;
done
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
:
create_jupytermachine_version
:
stage
:
create_jupytermachine_version
stage
:
create_jupytermachine_version
...
@@ -29,20 +53,21 @@ create_jupytermachine_version:
...
@@ -29,20 +53,21 @@ create_jupytermachine_version:
script
:
script
:
-
|
-
|
IMAGES=( "basis" "tp" "python311") # "tp_herwig") # "tp_geant" "cuda_basis"
IMAGES=( "basis" "tp" "python311") # "tp_herwig") # "tp_geant" "cuda_basis"
docker login -u
jeppelt
-p $DOCKER_TOKEN
docker login -u
$DOCKER_HUB_USER
-p $DOCKER_TOKEN
cd basis_jupytermachine
cd basis_jupytermachine
for image in "${IMAGES[@]}"; do
for image in "${IMAGES[@]}"; do
# Read the existing base image from the Dockerfile
# Read the existing base image from the Dockerfile
OLD_BASE_IMAGE=$(grep -E '^\s*FROM\s+.*' Dockerfile | awk '{print $2}');
OLD_BASE_IMAGE=$(grep -E '^\s*FROM\s+.*' Dockerfile | awk '{print $2}');
echo $OLD_BASE_IMAGE;
echo $OLD_BASE_IMAGE;
# Replace "basic_jupytermachine" with the new base image name
# Replace "basic_jupytermachine" with the new base image name
NEW_BASE_IMAGE=$
IMAGE_PREFIX
/etp_$image;
NEW_BASE_IMAGE=$
DOCKER_HUB_USER
/etp_$image;
echo $NEW_BASE_IMAGE;
echo $NEW_BASE_IMAGE;
sed -i "s#$OLD_BASE_IMAGE#$NEW_BASE_IMAGE#" "Dockerfile"
sed -i "s#$OLD_BASE_IMAGE#$NEW_BASE_IMAGE#" "Dockerfile"
cat Dockerfile;
cat Dockerfile;
# Build the second version of the container
# Build the second version of the container
docker build -t "$
IMAGE_PREFIX
/jupytermachine_${image}" -f "Dockerfile" . --no-cache;
docker build -t "$
DOCKER_HUB_USER
/jupytermachine_${image}" -f "Dockerfile" . --no-cache;
docker push "$
IMAGE_PREFIX
/jupytermachine_${image}";
docker push "$
DOCKER_HUB_USER
/jupytermachine_${image}";
# Revert the Dockerfile to its original state for other iterations
# Revert the Dockerfile to its original state for other iterations
sed -i "s#$NEW_BASE_IMAGE#$OLD_BASE_IMAGE#" "Dockerfile"
sed -i "s#$NEW_BASE_IMAGE#$OLD_BASE_IMAGE#" "Dockerfile"
done
done
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment