Created
March 7, 2022 19:24
-
-
Save srih4ri/5e8f6fb30d3c16c2f21202fc0ce1b2fc to your computer and use it in GitHub Desktop.
This is a deploy.sh used for updating a rails app from a git repo and restarting the app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is an old script which was used to deploy rails applications to production | |
# It mimics what `capistrano` would do. | |
# Leaving it here for archival. | |
PATH=$PATH:/opt/ree | |
prod_dir='/srv/rails/myapp' | |
# this dir needs to have something like : | |
# /srv/rails/myapp | |
# |-- current -> releases/20110915_144041/ | |
# |-- deploy.sh | |
# |-- releases | |
# `-- shared | |
cd $prod_dir | |
timestamp=$(date +%Y%m%d_%H%M%S) | |
mkdir -p releases/$timestamp | |
git clone /srv/git/myapp.git "releases/$timestamp" | |
rm -rf releases/$timestamp/.git | |
rm -f current | |
ln -s releases/$timestamp/ current | |
cp shared/config/database.yml current/config/database.yml | |
mkdir current/tmp | |
mkdir current/log/ | |
chmod a+w current/log/* | |
chmod a+w current/Gemfile.lock | |
ln -s "$prod_dir/shared/uploads" "$prod_dir/current/uploads" | |
cd current | |
/opt/ree/bin/bundle install | |
/opt/ree/bin/bundle exec rake db:migrate RAILS_ENV=production | |
touch current/tmp/restart.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment