Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4167 from GCTC-NTGC/task/update-deploy-scripts
Browse files Browse the repository at this point in the history
Task/update deploy scripts
  • Loading branch information
tristan-orourke authored Aug 4, 2020
2 parents 1ab2572 + 8c80296 commit ddcf596
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
13 changes: 11 additions & 2 deletions etc/scripts/deploy-instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ composer i --no-dev --optimize-autoloader && npm run prod && npm ci --production

3. Zip the TalentCloud folder, copy to server on TBS device.

4. WinSCP deploy.sh and TalentCloud.zip to your home directory.
4. WinSCP deploy.sh and deploy_talentcloud.sh and TalentCloud.zip to your home directory.

5. Set permissions and execute:
sudo chmod 775 deploy.sh
sudo ./deploy.sh
sudo chmod 775 deploy_talentcloud.sh
sudo ./deploy_talentcloud.sh



To deploy the Reserve app instead:
Same as above, except the zipped folder should be named TalentReserve.zip, and run ./deploy_reserve.sh instead.

To deploy to the dev server:
Same as above, except use deploy_dev_reserve.sh and deploy_dev_talentcloud.sh scripts.
56 changes: 33 additions & 23 deletions etc/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
#!/bin/bash

SRC=$1
APP_DIR=$2

# If SRC includes ".zip", remove it
SRC=${SRC//[.]zip/}

# Extract files
echo "Setting permissions of TalentCloud.zip...";
sudo chmod 777 TalentCloud.zip;
echo "Setting permissions of $SRC.zip...";
sudo chmod 777 $SRC.zip;

echo "Unzipping contents of TalentCloud.zip...";
sudo unzip -qq TalentCloud.zip;
echo "Unzipping contents of $SRC.zip...";
sudo unzip -qq $SRC.zip;

echo "Ensure storage/framework/cache/data directory exists...";
mkdir -p TalentCloud/storage/framework/cache/data;
sudo mkdir -p $SRC/storage/framework/cache/data;

echo "Ensure file upload directory exists...";
mkdir -p TalentCloud/storage/app/public/resources;
sudo mkdir -p $SRC/storage/app/public/resources;

# Set permissions
echo "Setting proper app permissions in TalentCloud:"
echo "Setting proper app permissions in $SRC:"

echo "Setting directory permissions...";
sudo find TalentCloud -type d -exec chmod 775 {} \;
sudo find $SRC -type d -exec chmod 775 {} \;

echo "Setting file permissions...";
sudo find TalentCloud -type f -exec chmod 664 {} \;
sudo find $SRC -type f -exec chmod 664 {} \;

echo "Setting SELinux security context...";
sudo chcon -Rt httpd_sys_content_t TalentCloud;
sudo chcon -Rt httpd_sys_content_t $SRC;

echo "Setting SELinux security context on writable directories...";
sudo chcon -Rt httpd_sys_rw_content_t TalentCloud/storage;
sudo chcon -Rt httpd_sys_rw_content_t $SRC/storage;

echo "Setting nginx as onwer of all files...";
sudo chown -Rf nginx:nginx TalentCloud;
sudo chown -Rf nginx:nginx $SRC;

# Backup and copy to /var/www
echo "Updating app with contents of TalentCloud:"
# Move the old Storage folder so it doesn't get deleted
echo "Saving previous Storage folder...";
sudo mv $APP_DIR/storage ./storage_backup;

echo "Copying TalentCloud to backup...";
sudo cp -R TalentCloud "TalentCloud_Backup";
# Copy to APP_DIR
echo "Updating app with contents of $SRC:";

echo "Deleting contents of app directory...";
sudo rm -Rf /var/www/*;
sudo rm -Rf $APP_DIR/*;

echo "Moving contents of TalentCloud to app directory...";
sudo mv TalentCloud/* /var/www/;
echo "Moving contents of $SRC to app directory...";
sudo mv $SRC/* $APP_DIR/;

echo "Deleting empty TalentCloud...";
sudo rm -R TalentCloud;
echo "Moving old Storage files back into new app directory...";
sudo mv ./storage_backup/* $APP_DIR/storage;
sudo rm ./storage_backup;

echo "Deleting empty src directory...";
sudo rm -R $SRC;

# Migrations and optimizing Laravel
echo "Moving to app directory...";
cd /var/www;
cd $APP_DIR;

echo "Executing Laravel commands...";
sudo php artisan route:clear;
Expand All @@ -57,7 +68,6 @@ sudo php artisan config:clear;

echo "Database migrations...";
sudo php artisan migrate -n --force;

echo "Restarting email queue...";
sudo php artisan queue:restart;

Expand Down
3 changes: 3 additions & 0 deletions etc/scripts/deploy_dev_reserve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

source ./deploy.sh TalentReserve.zip /var/www.combined/reserve
3 changes: 3 additions & 0 deletions etc/scripts/deploy_dev_talentcloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

source ./deploy.sh TalentCloud.zip /var/www.combined/talentcloud
3 changes: 3 additions & 0 deletions etc/scripts/deploy_reserve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

source ./deploy.sh TalentReserve.zip /var/www/reserve
3 changes: 3 additions & 0 deletions etc/scripts/deploy_talentcloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

source ./deploy.sh TalentCloud.zip /var/www/talentcloud

0 comments on commit ddcf596

Please sign in to comment.