<commit_before>#!/bin/bash

# Setup a docker compose container used to start the production application
# Setup application & database

DOCKER_COMPOSE_TAG="1.3.1"

# create container
docker create --name osmaxx-starter -v "$(pwd):/app"  -v "/var/run/docker.sock:/var/run/docker.sock"  -e "COMPOSE_PROJECT_NAME=osmaxx" "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" up --no-recreate

# stop containers & cleanup
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" stop
# remove all containers explicitly except the data container
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" \
rm -f webapp rabbitmq celery database email

# pull & build
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" pull
# build all containers explicitly except the data container
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" \
build webapp rabbitmq celery database email

# migrate
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" up -d database
sleep 10
# FIXME: create superuser should only be needed to be ran once.
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" -it --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" \
    run --rm webapp /bin/bash -c "python3 manage.py migrate && python3 manage.py createsuperuser"
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" stop
<commit_msg>cleanup of deployment script<commit_after>#!/bin/bash

# Setup a docker compose container used to start the production application
# Setup application & database

DOCKER_COMPOSE_TAG="1.3.1"

CONTAINERS_TO_BE_UPDATED='webapp celery'

function run_docker_compose_dduportal() {
 docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:${DOCKER_COMPOSE_TAG}" "${@}"
}
function run_docker_compose_dduportal_interactive() {
    docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" -it --rm "dduportal/docker-compose:${DOCKER_COMPOSE_TAG}" "${@}"
}

# create container
docker create --name osmaxx-starter -v "$(pwd):/app"  -v "/var/run/docker.sock:/var/run/docker.sock"  -e "COMPOSE_PROJECT_NAME=osmaxx" "dduportal/docker-compose:${DOCKER_COMPOSE_TAG}" up --no-recreate

# stop containers & cleanup
run_docker_compose_dduportal stop

# remove all containers explicitly except the data container
run_docker_compose_dduportal rm -f ${CONTAINERS_TO_BE_UPDATED}

# pull & build
run_docker_compose_dduportal pull

# build all containers explicitly except the data container
run_docker_compose_dduportal build ${CONTAINERS_TO_BE_UPDATED}

# migrate
run_docker_compose_dduportal up -d database

sleep 10

# FIXME: create superuser should only be needed to be ran once per deployment setup.
run_docker_compose_dduportal_interactive run --rm webapp /bin/bash -c "python3 manage.py migrate && python3 manage.py createsuperuser"

run_docker_compose_dduportal stop

{'fraction_non_alphanumeric': 0.13374370453273643, 'fraction_numerical': 0.00391717963066592, 'mean_word_length': 5.163793103448276, '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': '7349109', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1273, 'n_words': 295}