<commit_before>#!/bin/sh

# Script to build and push Docker images for each service.
#
# Checks for changes within each service's folder since the last tag. Only builds a new image
# if any changes are detected.
#
# Previously, we used Azure Pipelines' DockerCompose@0 task to build and push images for _all_
# the services defined in `docker-compose.yaml` for every version. This meant that on Docker Hub
# there was an image for every service, for every version. The downside was that builds took longer
# and there was unecessary churn e.g. a small fix to the `manager` service caused a new version of 
# the `broker` to be deployed by Flux CD. Downstream effects of this included unecessary 
# disconnections e.g. `worker` unable to find `broker` momentarily and associated warning notifications.

CURR=$(git describe --abbrev=0 --tags HEAD)
PREV=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))

for SERVICE in assistant broker cache database manager monitor overseer router scheduler steward worker
do
    case $SERVICE in
        assistant) DIR=manager  ;;
        *)         DIR=$SERVICE ;;
    esac

    git diff --quiet $CURR $PREV -- $DIR

    if [ $? -eq 1 ]
    then
        echo "$SERVICE: building and pushing $CURR"

        if [ $SERVICE = manager ]
        then
            echo "$SERVICE: building static assets"
            make -C manager static
        fi

        docker build --tag "stencila/hub-$SERVICE:$CURR" --tag "stencila/hub-$SERVICE:latest" $DIR
        docker push --all-tags "stencila/hub-$SERVICE"
    else
        echo "$SERVICE: no change between $PREV and $CURR"
    fi
done<commit_msg>ci(Docker): Push latest separately; use assistant.Dockerfile<commit_after>#!/bin/sh

# Script to build and push Docker images for each service.
#
# Checks for changes within each service's folder since the last tag. Only builds a new image
# if any changes are detected.
#
# Previously, we used Azure Pipelines' DockerCompose@0 task to build and push images for _all_
# the services defined in `docker-compose.yaml` for every version. This meant that on Docker Hub
# there was an image for every service, for every version. The downside was that builds took longer
# and there was unecessary churn e.g. a small fix to the `manager` service caused a new version of 
# the `broker` to be deployed by Flux CD. Downstream effects of this included unecessary 
# disconnections e.g. `worker` unable to find `broker` momentarily and associated warning notifications.

CURR=$(git describe --abbrev=0 --tags HEAD)
PREV=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))

for SERVICE in assistant broker cache database manager monitor overseer router scheduler steward worker
do
    if [ $SERVICE = assistant ]
        DIR=manager
        FILE=manager/assistant.Dockerfile
    else
        DIR=$SERVICE
        FILE=$SERVICE/Dockerfile
    fi

    git diff --quiet $CURR $PREV -- $DIR

    if [ $? -eq 1 ]
    then
        echo "$SERVICE: building and pushing $CURR"

        if [ $SERVICE = manager ]
        then
            echo "$SERVICE: building static assets"
            make -C manager static
        fi

        docker build --tag "stencila/hub-$SERVICE:$CURR" --tag "stencila/hub-$SERVICE:latest" --file $FILE $DIR
        docker push "stencila/hub-$SERVICE:$CURR"
        docker push "stencila/hub-$SERVICE:latest"
    else
        echo "$SERVICE: no change between $PREV and $CURR"
    fi
done
{'fraction_non_alphanumeric': 0.0882183908045977, 'fraction_numerical': 0.0034482758620689655, 'mean_word_length': 2.9646924829157175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '697534', 'n_tokens_mistral': 1013, 'n_tokens_neox': 977, 'n_words': 428}