-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates Dockerfile to allow version tag customization and refactors i…
…mage tagging and pushing in build script Introduces the ability to customize the version tag in the Dockerfile using an argument Streamlines the process of tagging and pushing Docker images to multiple registries in the build script Ensures consistency in versioning across different image registries
- Loading branch information
Showing
2 changed files
with
38 additions
and
26 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
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
#!/bin/bash | ||
version="24.4" | ||
# Define image name, version and registries | ||
image="cpuminer-opt" | ||
docker build . --tag docker.io/cniweb/$image:$version | ||
docker tag docker.io/cniweb/$image:$version docker.io/cniweb/$image:latest | ||
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:$version | ||
docker tag docker.io/cniweb/$image:$version ghcr.io/cniweb/$image:latest | ||
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:$version | ||
docker tag docker.io/cniweb/$image:$version quay.io/cniweb/$image:latest | ||
docker push docker.io/cniweb/$image:$version | ||
docker push docker.io/cniweb/$image:latest | ||
docker push ghcr.io/cniweb/$image:$version | ||
docker push ghcr.io/cniweb/$image:latest | ||
docker push quay.io/cniweb/$image:$version | ||
docker push quay.io/cniweb/$image:latest | ||
version="25.1" | ||
registries=("docker.io" "ghcr.io" "quay.io") | ||
|
||
# Build the image | ||
docker build . --build-arg VERSION_TAG=v$version --tag ${registries[0]}/cniweb/$image:$version | ||
|
||
# Check if the command was successful | ||
if [ $? -ne 0 ]; then | ||
echo "Docker build failed!" | ||
exit 1 | ||
fi | ||
|
||
echo "Docker build succeeded!" | ||
|
||
# Tag and push the images | ||
for registry in "${registries[@]}"; do | ||
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:$version | ||
docker tag ${registries[0]}/cniweb/$image:$version $registry/cniweb/$image:latest | ||
|
||
# Push both versioned and latest tags | ||
docker push $registry/cniweb/$image:$version | ||
docker push $registry/cniweb/$image:latest | ||
done |