Django
Deploy
docker
unicorn Dockerfile:
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
RUN python -m pip install gunicorn
COPY requirements.txt /code/
RUN pip install -r requirements.txt
compose:
version: '3'
services:
db:
restart: always
image: postgres
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
web:
restart: always
build:
context: .
dockerfile: docker/gunicorn/Dockerfile
command: gunicorn --env DJANGO_SETTINGS_MODULE=owl.settings --bind 0.0.0.0 owl.wsgi
volumes:
- .:/code
ports:
- "8081:8000"
environment:
- POSTGRES_NAME=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
depends_on:
- db
nginx:
server {
listen 80;
server_name wtcode.net; # customize with your domain name
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://192.168.2.2:8081/;
client_max_body_size 32m;
}
location /static/ {
# static files
alias /var/www/wtcode.net/static/; # ending slash is required
}
location /media/ {
# media files, uploaded by users
alias /var/www/wtcode.net/media/; # ending slash is required
}
}