-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.sh
executable file
·62 lines (43 loc) · 1.45 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# script to be run on the server, to deploy the application
# Ensure that $ENV_PATH is set
# You may use the export command to do like this or update the .bashrc
# export ENV_PATH="/workspaces/cred/.env"
# Ensure that docker is installed
REPO_URL=https://github.com/CDCRC-IITRPR/cdcrc_website
set -e
set -o pipefail
# Clone the repo if the directory doesn't exist
if [ ! -d "./cdcrc_website/" ]
then
echo "Cloning the repo.."
git clone "$REPO_URL"
else
echo "Directory Already exists!"
fi
echo "Changing directory to cdcrc_website/"
cd cdcrc_website
# changing the branch
git checkout prod --
git fetch --all
git reset --hard origin/prod
echo "Moving the env file from the \$ENV_PATH to current directory"
cp $ENV_PATH ./.env
sudo chmod +x startup.sh
# adding the command in nginx/Dockerfile.prod to use the ssl config
cat <<'EOT' >> nginx/Dockerfile.prod
COPY nginx_with_ssl.conf /etc/nginx/conf.d/nginx.conf
EOT
# Building
echo "Building the application"
docker-compose -f docker-compose.prod.yml build
echo "Stopping all containers"
docker-compose -f docker-compose.prod.yml down
echo "check if we need to renew any certificates"
certbot renew
echo "Removing static_webassets volume"
docker volume rm cdcrc_website_static_webassets
echo "Starting the application....."
docker-compose -f docker-compose.prod.yml up -d
echo "Executing the startup script"
./startup.sh docker-compose.prod.yml --collect-static
echo "Yipeee! Deployment complete."