Skip to content

Commit

Permalink
Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhii Polishchuk committed Oct 18, 2021
1 parent 8a5a40f commit 1f854ce
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
32 changes: 32 additions & 0 deletions deploy-ssr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e
set -o errexit

rm -rf dist

DOMAIN_PROD="theatre-shevchenko.ck.ua"
DOMAIN_STAGING="staging.theatre.pp.ua"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
SSH_HOST="geekhub-www"

#npm run lint
#npm run lint-css
#ng test --watch=false --browsers=ChromeHeadlessNoSandbox --code-coverage=true
#ng e2e

if [ "$BRANCH" = "master" ]; then DOMAIN=$DOMAIN_PROD; else DOMAIN="$DOMAIN_STAGING"; fi
if [ "$BRANCH" = "master" ]; then ENV="production"; else ENV="staging"; fi

./build-ssr.sh "$ENV"

cp ./deploy/branch.conf ./dist/
cp ./deploy/index.html ./dist/
cd dist/ && tar -zcvf ../dist.tar.gz * && cd -

scp dist.tar.gz $SSH_HOST:~/$DOMAIN.tar.gz
ssh $SSH_HOST "rm -rf ~/$DOMAIN && mkdir ~/$DOMAIN"
ssh $SSH_HOST "tar -xf ~/$DOMAIN.tar.gz -C ~/$DOMAIN"
ssh $SSH_HOST "mkdir ~/$DOMAIN/dist && mv ~/$DOMAIN/theatre-front ~/$DOMAIN/dist"
ssh $SSH_HOST "rm ~/$DOMAIN.tar.gz"

echo "Deployed to $DOMAIN"
9 changes: 9 additions & 0 deletions deploy/bin/domain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

export $(xargs < .env)

if [ "$BRANCH" = "master" ]; then DOMAIN=$DOMAIN_PROD; else DOMAIN="$DOMAIN_STAGING/$BRANCH"; fi
if [ "$BRANCH" = "master" ]; then ENV="production"; else ENV="staging"; fi
if [ "$BRANCH" = "master" ]; then BASE_HREF="/"; else BASE_HREF="/$BRANCH/"; fi

export $BRANCH
43 changes: 43 additions & 0 deletions deploy/ssr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
server {
listen 80;
server_name {{domain}};

root /var/www/{{domain}};

error_log /var/log/nginx/{{domain}}_error.log;
access_log /var/log/nginx/{{domain}}_access.log;

location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff|ttf|eot)$ {
expires 365d;
add_header Pragma public;
add_header Cache-Control "public";
}

location /uk/ {
proxy_pass http://127.0.0.1:{{uk_port}};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /en/ {
proxy_pass http://127.0.0.1:{{en_port}};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

0 comments on commit 1f854ce

Please sign in to comment.