Skip to content

Commit

Permalink
feat: try nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfromyeg committed Dec 31, 2023
1 parent 1e9d8f0 commit 4a13983
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ docker tag bereal-wrapped-cli:latest michaelfromyeg/bereal-wrapped-cli:latest
docker push michaelfromyeg/bereal-wrapped-cli
```

### Deployment

Opted for Digital Ocean. Cheap, easy, and supports `docker-compose`.

### Project Structure

* `main.py` the main flask app and drives webpage and API requests
Expand Down
35 changes: 35 additions & 0 deletions docker-compose-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.8"

services:
web:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./videos:/app/exports
user: thekid
ports:
- "5000:5000"
environment:
- FLASK_APP=bereal.server
depends_on:
- redis

celery:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./videos:/app/exports
user: thekid
command: celery -A bereal.celery worker --loglevel=INFO --logfile=celery.log -E
environment:
- FLASK_APP=bereal.server
depends_on:
- web
- redis

redis:
image: "redis:alpine"
ports:
- "6379:6379"
15 changes: 13 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- /data:/app/exports
- /mnt/videos:/app/exports
user: thekid
ports:
- "5000:5000"
Expand All @@ -20,7 +20,7 @@ services:
context: .
dockerfile: Dockerfile
volumes:
- /data:/app/exports
- /mnt/videos:/app/exports
user: thekid
command: celery -A bereal.celery worker --loglevel=INFO --logfile=celery.log -E
environment:
Expand All @@ -33,3 +33,14 @@ services:
image: "redis:alpine"
ports:
- "6379:6379"

nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- /path/to/ssl/certs:/etc/ssl/certs:ro # Mount SSL certificate and key
depends_on:
- web
24 changes: 24 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {
listen 80;
server_name api.bereal.michaeldemar.co;

return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
server_name api.bereal.michaeldemar.co;

# SSL configuration
ssl_certificate /fullchain.pem;
ssl_certificate_key /privkey.pem;

# web and port are from the service's definition in docker-compose
location / {
proxy_pass http://web:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

0 comments on commit 4a13983

Please sign in to comment.