<commit_before>#!/bin/sh
set -e

START_TIME=$(date +%s)

echo "=== Shutting down web container. ==============================================="
docker-compose stop web

# The backup process will fail if the db container is not started.

echo "=== Starting backup container. ================================================="
docker-compose up -d backup

echo "=== Backing up application stack. =============================================="
docker-compose exec backup app-backup

echo "=== Removing currnet application stack. ========================================"
docker-compose down

echo "=== Pulling changes from repo. ================================================="
git pull

echo "=== Updating environment file. ================================================="
OLD_CONFLUENCE_VERSION=$(grep ^CONFLUENCE_VERSION= .env | cut -d = -f 2)
NEW_CONFLUENCE_VERSION=$(grep ^CONFLUENCE_VERSION= .env.template | cut -d = -f 2)
echo "[I] Upgrading Confluence from '$OLD_CONFLUENCE_VERSION' to '$NEW_CONFLUENCE_VERSION'."
sed -i.bak "s/^CONFLUENCE_VERSION=.*/CONFLUENCE_VERSION=$NEW_CONFLUENCE_VERSION/g" .env

echo "=== Building new images. ======================================================="
docker-compose build --pull

echo "=== Pulling updated database image. ============================================"
docker-compose pull db

echo "=== Starting backup container. ================================================="
docker-compose up -d backup

echo "=== Restoring application stack to most recent backup. ========================="
cd backups
LATEST_BACKUP=$(ls -1tr *.tar.gz 2> /dev/null | tail -n 1)
cd ..
docker-compose exec backup app-restore $LATEST_BACKUP

END_TIME=$(date +%s)

echo "=== Upgrade complete. =========================================================="
echo "[I] Time elapsed: $((END_TIME-START_TIME)) seconds."<commit_msg>Delete old images before building new ones (a) to keep disk usage down and (b) instead of using the "--no-cache" option<commit_after>#!/bin/sh
set -e

START_TIME=$(date +%s)

echo "=== Shutting down web container. ==============================================="
docker-compose stop web

# The backup process will fail if the db container is not started.

echo "=== Starting backup container. ================================================="
docker-compose up -d backup

echo "=== Backing up application stack. =============================================="
docker-compose exec backup app-backup

echo "=== Removing currnet application stack. ========================================"
docker-compose down

echo "=== Pulling changes from repo. ================================================="
git pull

echo "=== Updating environment file. ================================================="
OLD_CONFLUENCE_VERSION=$(grep ^CONFLUENCE_VERSION= .env | cut -d = -f 2)
NEW_CONFLUENCE_VERSION=$(grep ^CONFLUENCE_VERSION= .env.template | cut -d = -f 2)
echo "[I] Upgrading Confluence from '$OLD_CONFLUENCE_VERSION' to '$NEW_CONFLUENCE_VERSION'."
sed -i.bak "s/^CONFLUENCE_VERSION=.*/CONFLUENCE_VERSION=$NEW_CONFLUENCE_VERSION/g" .env

echo "=== Deleting old images. ======================================================="
IMAGE_BACKUP=$(docker images ianharrier/confluence-backup -q)
IMAGE_WEB=$(docker images ianharrier/confluence -q)
docker rmi $IMAGE_BACKUP $IMAGE_WEB

echo "=== Building new images. ======================================================="
docker-compose build --pull

echo "=== Pulling updated database image. ============================================"
docker-compose pull db

echo "=== Starting backup container. ================================================="
docker-compose up -d backup

echo "=== Restoring application stack to most recent backup. ========================="
cd backups
LATEST_BACKUP=$(ls -1tr *.tar.gz 2> /dev/null | tail -n 1)
cd ..
docker-compose exec backup app-restore $LATEST_BACKUP

END_TIME=$(date +%s)

echo "=== Upgrade complete. =========================================================="
echo "[I] Time elapsed: $((END_TIME-START_TIME)) seconds."
{'fraction_non_alphanumeric': 0.36007875953728774, 'fraction_numerical': 0.002461235540241201, 'mean_word_length': 6.682419659735349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1035535', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1051, 'n_words': 323}