Using the docker-compose of the production environment of Django-Cookie-Cutter. Not sure if this still works because we deploy https://datenspende.dataskop.net/ in a different way.
docker-compose -f docker-compose.production.yml run --rm django python manage.py migrate
docker-compose -f docker-compose.production.yml run --rm django python manage.py createsuperuser
docker-compose -f docker-compose.production.yml --env-file .envs/.production/.django up
Protect the staging enviroment with basic auth.
htpasswd -c compose/production/traefik/htpasswd user
mkdir -p .envs/.production/.django && mkdir .envs/.production/.postgres
Here an example on how to deploy with Docker-Compose and systemd.
Some more details in the cookiecutter-django Docker documentation.
cd /etc/systemd/system
vim dataskop-staging.service
[Unit]
Description=dataskop (Staging)
After=docker.service
[Service]
Restart=on-failure
RestartSec=5s
Type=oneshot
RemainAfterExit=yes
StandardOutput=file:/var/log/goli.log
StandardError=file:/var/log/goli_error.log
WorkingDirectory=/root/code/dataskop/
ExecStart=/usr/bin/docker-compose -f docker-compose.production.yml --env-file .envs/.production/.django up -d
ExecStop=/usr/bin/docker-compose -f docker-compose.production.yml down
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable dataskop-staging.service
Usefull commands
systemctl enable dataskop-staging
systemctl status dataskop-staging
systemctl start dataskop-staging
systemctl stop dataskop-staging
Create a simple deployment script:
#!/usr/bin/env bash
rsync -avz --delete --exclude node_modules --exclude .git --exclude htpasswd . awlab2:~/code/dataskop
ssh awlab2 "cd code/dataskop && docker-compose -f docker-compose.production.yml up --detach --build && docker-compose -f docker-compose.production.yml run --rm django python manage.py migrate"
Create a volume (on the host) and assign the uid + guid of the user running django.
mkdir /var/dataskop_media_files
chown -R 101:101 /var/dataskop_media_files