make the database persistant in production

This commit is contained in:
stupidcomputer 2024-06-28 17:04:45 -05:00
parent d5e74175e6
commit 07dd23a396
5 changed files with 16 additions and 1 deletions

View File

@ -4,3 +4,7 @@ prod: # execute this target on the production server in the nix-shell
sed "s/change_me/$(shell shuf -i1-1000000 -n1)/g" .env.prod.orig > .env.prod
sed "s|change_me|$(shell dd if=/dev/urandom bs=1024 count=1|base64)|g" .env.prod.orig > .env.prod
docker-compose -f docker-compose.prod.yml up -d --build
permissions:
chmod -f 660 db.sqlite3
echo "make sure that db.sqlite3 is owned by group users"

View File

@ -5,7 +5,12 @@ services:
dockerfile: Dockerfile.prod
command: gunicorn franklincce.wsgi:application --bind 0.0.0.0:8000
volumes:
- static_volume:/home/app/web/staticfiles
- type: volume
source: static_volume
target: /home/app/web/staticfiles
- type: bind
source: ./db.sqlite3
target: /home/app/web/db.sqlite3
expose:
- 8000
env_file:
@ -20,3 +25,4 @@ services:
- web
volumes:
static_volume:
db_persist:

View File

@ -22,6 +22,7 @@ RUN mkdir -p /home/app
# create the app user
RUN addgroup --system app && adduser --system --group app
RUN usermod -a -G users app
# create the appropriate directories
ENV HOME=/home/app

View File

@ -1,3 +1,6 @@
#!/bin/sh
python3 manage.py makemigrations
python3 manage.py migrate
exec "$@"

View File

@ -10,6 +10,7 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
client_max_body_size 100M;
}
location /static/ {