Skip to content

Commit

Permalink
feat(traefik): deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD committed Aug 13, 2022
1 parent 3f503ad commit 44f5959
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/service/traefik-proxy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HOST=0.0.0.0
DOMAIN=srv1.mihandoost.com
AUTH='alwatr:$apr1$9jctC6HA$EC97JQSxhmoxk6RCUJqih0'

# https://hub.docker.com/r/library/traefik/
TRAEDIK_IMAGE=traefik:v1.7-alpine
1 change: 1 addition & 0 deletions packages/service/traefik-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Alwatr Edge Reverse Proxy
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ chmod 600 _data/acme.json
echoStep "Starting..."
docker-compose pull
# docker-compose build --pull
docker-compose up --detach --remove-orphans --force-recreate
docker-compose up --detach --remove-orphans # --force-recreate

echoStep "Done"

docker-compose logs --tail=1000 --follow
docker-compose logs --tail=300 --follow || true
42 changes: 42 additions & 0 deletions packages/service/traefik-proxy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -Eeuo pipefail
trap "echo '❌ Error'" ERR

thisPath="$(pwd)"
projectName="$(basename "$thisPath")"
cd $thisPath;

user=root
host=srv1

echoStep () {
echo "🔸 $1"
}

remoteShell() {
server=$1; shift;
echo "🔸 remoteShell => $server"
ssh -o "ConnectTimeout=5" -tt -q $server $@ || echo "❌ remoteShell error for $server"
}

if [ ! -f .env ]
then
echo "❌ .env file not found"
cp .env.example .env
nano .env
fi

echoStep "Sync..."

remoteShell $user@$host "mkdir -p /srv/$projectName"

rsync -Pazh --del ./_*.sh ./.env ./*.yml ./*.toml $user@$host:/srv/$projectName

if [[ "${1:-}" == "--down" ]]
then
echoStep "Down..."
remoteShell $user@$host "cd /srv/$projectName && docker-compose down --remove-orphans"
else
echoStep "Up..."
remoteShell $user@$host "cd /srv/$projectName && chmod +x _up.sh && ./_up.sh"
fi
4 changes: 2 additions & 2 deletions packages/service/traefik-proxy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ networks:

services:
service-proxy:
image: ${PROXY_IMAGE}
image: ${TRAEDIK_IMAGE}

hostname: "alwatr-traefik-proxy"
hostname: "traefik-proxy.alwatr.io"

networks:
- alwatr-public-network
Expand Down

0 comments on commit 44f5959

Please sign in to comment.