- Release script added to tag in both git and docker

This commit is contained in:
Josako
2024-10-21 07:45:06 +02:00
parent 5e77b478dd
commit 30fec27488

23
docker/release_and_tag_eveai.sh Normal file → Executable file
View File

@@ -31,24 +31,25 @@ fi
# Path to your docker-compose file
DOCKER_COMPOSE_FILE="compose_dev.yaml"
# Get all the services defined in the docker-compose file
SERVICES=$(docker-compose -f $DOCKER_COMPOSE_FILE config --services)
# Get all the images defined in docker-compose
IMAGES=$(docker compose -f $DOCKER_COMPOSE_FILE config | grep 'image:' | awk '{ print $2 }')
# Tag and push images for all services that belong to your Docker account
for SERVICE in $SERVICES; do
DOCKER_IMAGE="your-docker-repo/$SERVICE"
# Start tagging only relevant images
for DOCKER_IMAGE in $IMAGES; do
# Check if the image belongs to your Docker account and ends with :latest
if [[ $DOCKER_IMAGE == $DOCKER_ACCOUNT* && $DOCKER_IMAGE == *:latest ]]; then
# Remove the ":latest" tag to use the base image name
BASE_IMAGE=${DOCKER_IMAGE%:latest}
# Check if the image starts with your Docker account name
if [[ $DOCKER_IMAGE == $DOCKER_ACCOUNT* ]]; then
echo "Tagging Docker image for service: $SERVICE with version: $RELEASE_VERSION"
echo "Tagging Docker image: $BASE_IMAGE with version: $RELEASE_VERSION"
# Tag the 'latest' image with the new release version
docker tag $DOCKER_IMAGE:latest $DOCKER_IMAGE:$RELEASE_VERSION
docker tag $DOCKER_IMAGE $BASE_IMAGE:$RELEASE_VERSION
# Push the newly tagged image to Docker Hub
docker push $DOCKER_IMAGE:$RELEASE_VERSION
docker push $BASE_IMAGE:$RELEASE_VERSION
else
echo "Skipping service: $SERVICE (not part of Docker account $DOCKER_ACCOUNT)"
echo "Skipping image: $DOCKER_IMAGE (not part of $DOCKER_ACCOUNT or not tagged as latest)"
fi
done