Skip to content

Commit

Permalink
Merge pull request #2 from gwu-libraries/CD-redeploy-setup
Browse files Browse the repository at this point in the history
First pass at redeploy script for CD
  • Loading branch information
alepbloyd authored Aug 22, 2024
2 parents 168a1bb + d83f96a commit c6739df
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions script/cd-redeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Change directory to the bookworm folder
cd /opt/bookworm
# Stash any local changes
git stash
# Checkout main branch if not already on it
git checkout main
# Pull any changes
git pull
# Stop and remove containers
docker compose down
# Remove locally built images
echo "Deleting locally built Docker images"
docker image rm $(docker images "bookworm-**" -q)
# Delete app volume
echo "Deleting app volume"
# Build containers
echo "Building docker images"
docker compose build
# Restart containers
echo "Restarting Docker containers"
docker compose up -d
# Run Database migrations if necessary
echo "Running Database Migrations"
docker exec -i $(docker ps --filter name=rails -q) bash -lc "bundle exec rails db:migrate RAILS_ENV=production"

0 comments on commit c6739df

Please sign in to comment.