Skip to content

Commit

Permalink
Merge pull request #1365 from devinit/fix/compose-command
Browse files Browse the repository at this point in the history
Fix compose invalid host errors
  • Loading branch information
wakibi authored Nov 27, 2023
2 parents ce09818 + 52ddcdb commit 265fd3f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ function backup_database {

cd $APP_DIR

log "Starting backup from remote docker machine $(docker-compose ps -q db)"
docker-compose exec -T db pg_dump -U di_website -d di_website > $file_name
log "Starting backup from remote docker machine $(docker compose ps -q db)"
docker compose exec -T db pg_dump -U di_website -d di_website > $file_name

log "Database backup completed..."

Expand All @@ -125,7 +125,7 @@ function search_reindex {
start_new_process "Re-indexing search"
cd $APP_DIR
sleep 60s
docker-compose exec -T ${new_state} python manage.py update_index
docker compose exec -T ${new_state} python manage.py update_index

}

Expand Down Expand Up @@ -209,14 +209,14 @@ function setup_blue_green_deployment {
npm run build

# Attempt to stop new container. Sometimes there is a hanging one still running...
docker-compose stop ${new_state}
docker compose stop ${new_state}
# update the new state container
echo "Update the ${new_state} container"
docker-compose up -d ${new_state}
docker compose up -d ${new_state}

# Check the new state container is ready
echo "Check the ${new_state} container is ready"
docker-compose run --rm --entrypoint /bin/bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
docker compose run --rm --entrypoint /bin/bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
chmod +x ./scripts/activate.sh
./scripts/activate.sh ${new_state} ${state} ${new_upstream} ${key_value_store}

Expand All @@ -230,7 +230,7 @@ function setup_blue_green_deployment {
docker tag diwebsite-redesign_web:new diwebsite-redesign_web:latest

echo "Stop the ${state} container"
docker-compose stop ${state}
docker compose stop ${state}
}

if [ ${args[0]} == 'run' ]
Expand Down Expand Up @@ -261,12 +261,12 @@ then
#run this script within this subprocess
chmod +x scripts/*
source scripts/init.sh
docker-compose -f docker-compose-consul.yml up -d
docker compose -f docker-compose-consul.yml up -d
setup_blue_green_deployment
search_reindex

start_new_process "Generating static assets"
docker-compose exec -T ${new_state} python manage.py collectstatic --noinput
docker compose exec -T ${new_state} python manage.py collectstatic --noinput
sudo chown -R di_website:di_website assets

exit 0
Expand Down
4 changes: 2 additions & 2 deletions scripts/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ new_state=$1
old_state=$2
new_upstream=$3
key_value_store=$4
was_state=$(docker-compose run --rm nginx curl ${key_value_store}?raw)
was_state=$(docker compose run --rm nginx curl ${key_value_store}?raw)

pid_was=$(docker exec nginx pidof nginx 2> /dev/null || echo '-')
echo "Activate the ${new_state} container, old Nginx pids: ${pid_was}"

echo "Set the ${new_state} container as working"
docker-compose run --rm nginx curl -X PUT -d ${new_state} ${key_value_store} > /dev/null
docker compose run --rm nginx curl -X PUT -d ${new_state} ${key_value_store} > /dev/null

if [[ ${pid_was} != '-' ]]
then
Expand Down
2 changes: 1 addition & 1 deletion scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ then
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:blue
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:green
# cd .
docker-compose up --build -d
docker compose up --build -d
fi
4 changes: 2 additions & 2 deletions scripts/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ key_value_store=$1
state=$2

echo 'Set the previous container as working'
docker-compose run --rm nginx curl -X PUT -d ${state} ${key_value_store} > /dev/null
docker compose run --rm nginx curl -X PUT -d ${state} ${key_value_store} > /dev/null

echo 'Stop the ${old_state} container'
docker-compose stop ${state}
docker compose stop ${state}

echo 'Remove the new image'
docker tag diwebsite-redesign_web:latest diwebsite-redesign_web:new
6 changes: 3 additions & 3 deletions scripts/rollback.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ echo "Create the diwebsite-redesign_web:${new_state} image"
docker tag diwebsite-redesign_web:new diwebsite-redesign_web:${new_state}

echo "Update the ${new_state} container"
docker-compose up -d ${new_state}
docker compose up -d ${new_state}

echo "Check the ${new_state} container is ready"
docker-compose run --rm --entrypoint bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60
docker compose run --rm --entrypoint bash ${new_state} ./scripts/wait-for-it.sh ${new_state}:8090 --timeout=60

./activate.sh ${new_state} ${state} ${new_upstream} ${key_value_store}

echo "Set the ${new_state} image as ${state}"
docker tag diwebsite-redesign_web:${new_state} diwebsite-redesign_web:${state}

echo "Stop the ${state} container"
docker-compose stop ${state}
docker compose stop ${state}

0 comments on commit 265fd3f

Please sign in to comment.