<commit_before>#!/bin/bash
echo "Put repo in src format somewhere."
mkdir -p /home/git/src/$1 && cat | tar -x -C /home/git/src/$1
echo "Building Docker image."
BASE=`basename $1 .git`
echo "Base: $BASE"
# TODO: Find out the old container ID.
sudo docker build -t nonfiction/$BASE /home/git/src/$1
ID=$(sudo docker run -P -d nonfiction/$BASE)
# Get the $PORT from this container.
PORT=$(sudo docker port $ID 5000 | sed 's/0.0.0.0://')
echo "$BASE is running on port $PORT"

# Connect $BASE.handbill.io to the $PORT
/usr/bin/redis-cli rpush frontend:$BASE.handbill.io $BASE
/usr/bin/redis-cli rpush frontend:$BASE.handbill.io http://127.0.0.1:$PORT

# Kill the old container by ID.<commit_msg>Killing the old container and port if there is one.<commit_after>#!/bin/bash
echo "Put repo in src format somewhere."
mkdir -p /home/git/src/$1 && cat | tar -x -C /home/git/src/$1
echo "Building Docker image."
BASE=`basename $1 .git`
echo "Base: $BASE"

# Find out the old container ID.
OLD_ID=$(sudo docker ps | grep "$BASE:latest" | cut -d ' ' -f 1)
OLD_PORT=$(sudo docker inspect $OLD_ID | grep "HostPort" | cut -d ':' -f 2 | cut -d '"' -f 2)

# Build and get the ID.
sudo docker build -t nonfiction/$BASE /home/git/src/$1
ID=$(sudo docker run -P -d nonfiction/$BASE)
# Get the $PORT from the container.
PORT=$(sudo docker port $ID 5000 | sed 's/0.0.0.0://')

# Connect $BASE.handbill.io to the $PORT
/usr/bin/redis-cli rpush frontend:$BASE.handbill.io $BASE
/usr/bin/redis-cli rpush frontend:$BASE.handbill.io http://127.0.0.1:$PORT

# Kill the old container by ID.
if [ -n "$OLD_ID" ]
then
  echo "Killing $OLD_ID"
  sudo docker kill $OLD_ID
else
  echo "Not killing anything."
fi

# Remove the old port.
if [ -n "OLD_PORT" ]
then
  echo "Removing $OLD_PORT for $BASE."
else
  echo "Not removing any port."
fi
{'fraction_non_alphanumeric': 0.1562326869806094, 'fraction_numerical': 0.021606648199445983, 'mean_word_length': 3.526315789473684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '2912114', 'n_tokens_mistral': 713, 'n_tokens_neox': 649, 'n_words': 233}