Skip to content

Commit

Permalink
added backend proxy and automatic https SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdksh committed Aug 13, 2024
1 parent cacbda6 commit edc58c7
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .caddy.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MY_URL="https://mydomain.com"
IP_WHITELIST="0.0.0.0/0"
5 changes: 2 additions & 3 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ jobs:
cd QAcc-BE
git checkout staging
git pull
docker compose -f docker-compose-staging.yml stop qacc-be
docker compose -f docker-compose-staging.yml pull qacc-be
docker compose -f docker-compose-staging.yml up -d
docker compose -f docker-compose-staging.yml build --no-cache
docker compose -f docker-compose-staging.yml up -d --build
docker image prune -a --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ src/scripts/*.json
./src/server/adminJs/adminjs

.DS_Store
.caddy.env
10 changes: 10 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{$MY_URL} {
route {
@allowed {
path /*
remote_ip {$IP_WHITELIST}
}
reverse_proxy @allowed qacc-be:4000
respond 403
}
}
33 changes: 31 additions & 2 deletions docker-compose-staging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
services:
qacc-be:
container_name: qacc-be
image: ghcr.io/generalmagicio/qacc-be:staging
build: .
#image: ghcr.io/generalmagicio/qacc-be:staging
command: npm run start:docker:server
environment:
- ENVIRONMENT=production
Expand All @@ -11,6 +12,8 @@ services:
- ./config:/usr/src/app/config
- ./config:/usr/src/app/build/config
- ./logs:/usr/src/app/logs
networks:
- qacc
ports:
- "4001:4000"

Expand All @@ -22,8 +25,34 @@ services:
restart: always
volumes:
- redis-data:/data
networks:
- qacc
ports:
- "6379:6379"

caddy:
image: caddy:2-alpine
container_name: caddy
restart: unless-stopped
networks:
- qacc
ports:
- 80:80
- 443:443
env_file:
- .caddy.env
environment:
MY_URL=${MY_URL:-}
IP_WHITELIST=${IP_WHITELIST:-}
volumes:
- caddy_data:/data
- caddy_config:/config
- ./Caddyfile:/etc/caddy/Caddyfile

volumes:
redis-data:
redis-data:
caddy_config:
caddy_data:

networks:
qacc:

0 comments on commit edc58c7

Please sign in to comment.