First implementation of Docker support

This commit is contained in:
Michael Herrmann
2023-11-14 08:43:22 +08:00
parent f592a1f0b9
commit 89aee17c2e
6 changed files with 80 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/home/michael/dev/api.winget.pro/.gitignore
+3
View File
@@ -73,6 +73,9 @@ Upload [`install.sh`](install.sh) and a `.bashrc` file with the settings below
to a Debian 11 server, then run `install.sh` as root.
```bash
# Set DEBUG to False in production:
export DEBUG=False
# The domain under which this server runs:
export HOST_NAME=some.domain.com
+1
View File
@@ -0,0 +1 @@
*
+19
View File
@@ -0,0 +1,19 @@
FROM python:3.9
ENV DEBUG=False
ENV HOST_NAME=*
WORKDIR /srv
COPY . .
RUN pip install --no-cache-dir -Ur requirements/base-full.txt
RUN python manage.py migrate
RUN python manage.py collectstatic --noinput
EXPOSE 8000
CMD ["gunicorn", "core.wsgi:application", "--bind", "0.0.0.0:8000", \
"--log-level=warning", "--log-file=-"]
+24
View File
@@ -0,0 +1,24 @@
version: '3.8'
services:
django:
build:
context: ..
dockerfile: deploy/Dockerfile
volumes:
- static:/srv/static
- media:/srv/media
nginx:
image: nginx:1.25.3
volumes:
- static:/srv/static
- media:/srv/media
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "8000:80"
depends_on:
- django
volumes:
static:
media:
+32
View File
@@ -0,0 +1,32 @@
# The events block is required; We need to supply it, even if empty:
events {}
http {
# Make Nginx serve CSS files as text/css instead of text/plain. Otherwise,
# the browser does not apply styles:
include /etc/nginx/mime.types;
upstream django {
server django:8000;
}
server {
listen 80;
location /static/ {
alias /srv/static/;
}
location /media/ {
alias /srv/media/;
}
location / {
proxy_pass http://django;
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;
}
}
}