Skip to content

Commit

Permalink
Add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
psiemens committed Dec 5, 2024
1 parent d166614 commit 830e380
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ jobs:
# - name: Set tag in docker-compose.yml
# run: sed -i "s/\${TAG}/${{ github.ref }}/" docker-compose.yml

- name: Update docker-compose.yml
- name: Upload Docker Compose configuration
run: scp docker-compose.yml staging:/opt/ubyssey.ca/docker-compose.yml

- name: Upload nginx configuration
run: scp -r nginx staging:/opt/ubyssey.ca/nginx

- name: Restart services
run: ssh staging 'docker compose -f /opt/ubyssey.ca/docker-compose.yml -p ubyssey up -d'
25 changes: 20 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,30 @@ services:
GOOGLE_APPLICATION_CREDENTIALS: /run/secrets/GOOGLE_APPLICATION_CREDENTIALS
secrets:
- GOOGLE_APPLICATION_CREDENTIALS
ports:
- "8000:8000"
- "4444:4444"
expose:
- 8000
depends_on:
db:
condition: service_healthy
restart: true
stdin_open: true
tty: true

nginx:
image: nginx:latest
ports:
- 80:80
- 443:443
restart: always
volumes:
- ./nginx/conf.d/:/etc/nginx/conf.d/:ro
- ./certbot/www/:/var/www/certbot/:ro
depends_on:
- django

certbot:
image: certbot/certbot:latest
volumes:
- ./certbot/www/:/var/www/certbot/:rw
- ./certbot/conf/:/etc/letsencrypt/:r

secrets:
GOOGLE_APPLICATION_CREDENTIALS:
Expand Down
16 changes: 16 additions & 0 deletions nginx/conf.d/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
upstream django {
server django:8000;
}

server {

listen 80;

location / {
proxy_pass http://django;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}

}

0 comments on commit 830e380

Please sign in to comment.