1
0

Add live deployment files

This commit is contained in:
Marcel Schwarz 2023-07-24 20:25:48 +02:00
parent e2dbae13ee
commit d6e48d13d7
4 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,11 @@
FROM python:3.10
COPY clubhaus/requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
RUN pip3 install gunicorn~=20.1.0
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DEBUG_MODE=False
WORKDIR /usr/src/app

View File

@ -0,0 +1,2 @@
# Notes
- Use `chown -R www-data:www-data static/` and `chown -R www-data:www-data media/` to give nginx access to the files. Fixes the 403 error when accessing static files

View File

@ -0,0 +1,20 @@
version: "3"
services:
backend:
container_name: clubhaus_backend
image: icaotix/clubhaus_backend
build:
context: ../../
dockerfile: Deployment/Live/Dockerfile.python
command: gunicorn clubhaus.wsgi:application --bind 0.0.0.0:12000
volumes:
- ../../clubhaus:/usr/src/app
environment:
- ALLOWED_HOSTS=clubhaus-schornbach.de
- CSRF_TRUSTED_ORIGINS=https://clubhaus-schornbach.de
- SESSION_COOKIE_SECURE=True
- IP_RATE_LIMIT_TIME=3600
- DEBUG_MODE=False
- LC_ALL=de_DE.UTF-8
ports:
- "127.0.0.1:12000:12000"

View File

@ -0,0 +1,42 @@
upstream clubhaus_website {
server 127.0.0.1:12000;
}
server {
server_name clubhaus-schornbach.de;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/clubhaus-schornbach.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/clubhaus-schornbach.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / {
proxy_pass http://127.0.0.1:12000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $host;
proxy_redirect off;
# allow uploads up to 20 megabytes (like pictures)
client_max_body_size 20M;
}
# redirect static files to filesystem
location /static/ {
alias /usr/projects/clubhaus/clubhaus/static/;
}
# redirect media files to filesystem (user uploaded files)
location /media/ {
alias /usr/projects/clubhaus/clubhaus/media/;
}
}
server {
if ($host = clubhaus-schornbach.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name clubhaus-schornbach.de;
listen 80;
return 404; # managed by Certbot
}