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 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 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 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 dockerfile: Dockerfile.prod
command: gunicorn franklincce.wsgi:application --bind 0.0.0.0:8000 command: gunicorn franklincce.wsgi:application --bind 0.0.0.0:8000
volumes: 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: expose:
- 8000 - 8000
env_file: env_file:
@ -20,3 +25,4 @@ services:
- web - web
volumes: volumes:
static_volume: static_volume:
db_persist:

View File

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

View File

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

View File

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