Skip to content
Permalink
Browse files

update deploy scripts

  • Loading branch information...
binary010100 committed Jan 26, 2019
1 parent 705e3f8 commit be75109eea84105fb990f2bf06cff98e98a5bbcc
Showing with 64 additions and 112 deletions.
  1. +0 −42 deploy/deploy-docker.sh
  2. +39 −8 deploy/deploy.sh
  3. +0 −40 deploy/install-docker.sh
  4. +24 −21 deploy/install.sh
  5. +1 −1 server/setup.sh

This file was deleted.

Oops, something went wrong.
@@ -1,20 +1,51 @@
#!/bin/bash

# Exit on first error
set -e

prodServer="51.77.203.203"
ppServer="137.74.45.69"
port="1983"

if [ $# -lt 1 ]; then
echo "env is mandatory"
exit;
fi

env=$1
branch=$(git branch | grep \* | cut -d ' ' -f2)

git pull origin master
git push origin $branch
if [ "$env" != "pp" ] && [ "$env" != "prod" ] ; then
echo "wrong env $env"
exit
fi

server="137.74.45.69"
port="1983"
if [ $# -lt 2 ]; then
tag=$2
fi

currentBranch=$(git branch | grep \* | cut -d ' ' -f2)

echo "current branch > $currentBranch"

git pull origin $currentBranch
git push origin $currentBranch

server=$ppServer

if [ "$env" == "prod" ]; then
server=$prodServer
echo -n "Are you sur you want to deploy $tag to $env (y/n)? "
read answer
else
tag=$currentBranch
answer=y
fi

if echo "$answer" | grep -iq "^y" ;then

# If prod then create tag
if [ "$env" == "prod" ]; then
git tag $tag -m "new release $tag" || true
git push origin $tag
fi

ssh -p $port mawaqit@$server 'bash -s' < deploy/install.sh $env $branch
ssh -p $port mawaqit@$server 'bash -s' < deploy/install.sh $env $tag
fi

This file was deleted.

Oops, something went wrong.
@@ -1,42 +1,45 @@
#!/bin/bash

# Exit on first error
set -e

if [ $# -lt 2 ]; then
echo "env and branch are mandatory"
exit;
fi

env=$1
branch=$2
tag=$2
baseDir=/var/www/mawaqit
repoDir=$baseDir/repo
dockerContainer=mawaqit

cd $repoDir

git checkout $branch && git pull origin $branch
docker exec $dockerContainer git fetch && git checkout $tag

echo "Creating symlinks"
ln -snf $repoDir/web/robots.txt.$env $repoDir/web/robots.txt
docker exec $dockerContainer sh -c "(cd web && ln -snf robots.txt.$env robots.txt)"

echo "Set version"
version=dev@`git rev-parse --short HEAD`
sed -i "s/version: .*/version: $version/" app/config/parameters.yml
if [ "$env" == "prod" ]; then
version=$tag
fi

# install vendors and assets
export SYMFONY_ENV=prod
composer install --no-dev -n -o
bin/console assets:install -e prod --no-debug
bin/console assetic:dump -e prod --no-debug
docker exec $dockerContainer sed -i "s/version: .*/version: $version/" app/config/parameters.yml

# migrate DB
bin/console doctrine:migrations:migrate -n --allow-no-migration -e prod
# Install vendors and assets
docker exec $dockerContainer sh -c "SYMFONY_ENV=prod composer install -o -n --no-dev"
docker exec $dockerContainer bin/console assets:install -e prod --no-debug
docker exec $dockerContainer bin/console assetic:dump -e prod --no-debug

echo "Reset opcache"
curl -s localhost:81/reset_opcache.php
# Migrate DB
docker exec $dockerContainer bin/console doc:mig:mig -n --allow-no-migration -e prod

# Restart php
docker exec $dockerContainer kill -USR2 1

# Sync DB if prod deploy
if [ "$env" == "prod" ]; then
echo "Sync DB"
$baseDir/tools/dbSync.sh
fi

echo ""
echo "####################################################"
echo "The upgrade has been successfully done ;)"
echo "The upgrade to $tag has been successfully done ;)"
echo "####################################################"
@@ -26,4 +26,4 @@ sudo echo "AddressFamily inet" >> /etc/ssh/sshd_config

# Customise .bashrc
echo "cd /var/www/mawaqit" >> ~/.bashrc
echo "alias dock=\"docker exec -it --user $(id -u):$(id -g)\"" >> ~/.bashrc
echo "alias dock=\"docker exec -it --user $(id -u):$(id -g) mawaqit\"" >> ~/.bashrc

0 comments on commit be75109

Please sign in to comment.
You can’t perform that action at this time.