public-health-ch/Makefile

121 lines
3.2 KiB
Makefile
Raw Normal View History

2017-04-08 14:32:52 +02:00
export COMPOSE_FILE=./docker-compose.yml
export COMPOSE_PROJECT_NAME=publichealth
2020-05-16 17:53:03 +02:00
export EMAIL=change_me@localhost.localhost
2017-04-08 14:32:52 +02:00
default: build
2019-01-10 10:38:52 +01:00
upgrade:
docker-compose pull
2017-04-08 14:32:52 +02:00
build-cached:
docker-compose build
build:
docker-compose build --no-cache
2017-05-05 16:35:06 +02:00
run-here:
2017-04-08 14:32:52 +02:00
docker-compose stop web # for restart cases, when already running
docker-compose up
2017-05-05 16:35:06 +02:00
run:
docker-compose up -d --restart=always # detach by default
2017-04-08 14:32:52 +02:00
2017-05-05 16:35:06 +02:00
restart:
2017-04-08 14:32:52 +02:00
docker-compose stop web
docker-compose up -d web
stop:
docker-compose stop
migrate:
docker-compose exec web ./manage.py migrate
migrations:
2017-05-05 16:35:06 +02:00
docker-compose exec web ./manage.py makemigrations --merge
2017-04-08 14:32:52 +02:00
apply-migrations: migrations migrate
setup:
docker-compose exec web ./manage.py migrate
2020-05-16 17:53:03 +02:00
docker-compose exec web ./manage.py createsuperuser --username admin --email $(EMAIL) --noinput
2017-04-08 14:32:52 +02:00
2020-05-16 18:44:51 +02:00
rebuild:
2019-01-10 10:38:52 +01:00
docker-compose pull
2020-05-16 19:01:32 +02:00
docker-compose build web
2017-04-08 14:32:52 +02:00
docker-compose stop web
docker-compose kill web
2020-05-16 18:44:51 +02:00
compress:
2019-09-09 19:38:13 +02:00
docker-compose exec web ./manage.py collectstatic --noinput -i media
2017-05-05 16:57:28 +02:00
docker-compose exec web ./manage.py compress
2017-04-08 14:32:52 +02:00
2020-05-18 14:16:38 +02:00
release: rebuild compress run
2020-05-16 18:44:51 +02:00
2017-05-03 23:13:30 +02:00
reindex:
docker-compose exec web ./manage.py update_index
2017-05-04 00:07:07 +02:00
clear_index:
docker-compose exec elasticsearch curl -XDELETE localhost:9200/_all
2017-04-08 14:32:52 +02:00
django-exec-bash:
2017-05-05 16:57:28 +02:00
# execute bash in the currently running container
2017-04-08 14:32:52 +02:00
docker-compose exec web bash
django-run-bash:
# run new django container, with bash, and remove it after usage
docker-compose run --rm --no-deps web bash
django-shell:
docker-compose exec web ./manage.py shell
logs:
2020-05-16 21:15:23 +02:00
docker-compose exec web tail /var/log/wagtail/publichealth.log /var/log/wagtail/wagtail.log /var/log/wagtail/error.log
docker-logs:
2017-04-08 14:32:52 +02:00
docker-compose logs -f --tail=500
2019-10-17 17:05:01 +02:00
backup-data:
2020-05-15 21:53:01 +02:00
docker-compose exec web ./manage.py dumpdata --natural-foreign -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailcore.GroupPagePermission -e wagtailimages.rendition -e sessions -e feedler.feedlysettings > ~/publichealth.home.json
2017-05-16 11:59:48 +02:00
zip ~/publichealth.home.json.`date +"%d%m%Y-%H%M"`.zip ~/publichealth.home.json
rm ~/publichealth.home.json
2019-10-17 17:05:01 +02:00
backup-images:
2018-06-18 16:18:16 +02:00
echo "Backing up images ..."
2019-10-17 17:05:01 +02:00
sudo chown -R ansible media
2018-06-18 16:18:16 +02:00
zip -ruq ~/media.zip media
2017-04-25 16:00:32 +02:00
2019-10-17 17:05:01 +02:00
backup: backup-data backup-images
2017-04-25 16:00:32 +02:00
django-loaddata:
gunzip ~/publichealth.home.json.gz
docker-compose exec web ./manage.py loaddata ~/publichealth.home.json
2017-05-05 16:35:06 +02:00
restore: django-loaddata restart
2017-04-25 16:00:32 +02:00
psql:
docker-compose exec postgres psql -U postgres -d postgres
2017-04-08 14:32:52 +02:00
pg-run-detached:
2017-04-25 16:00:32 +02:00
# start pg service
docker-compose up -d postgres
2017-04-08 14:32:52 +02:00
pg-exec:
2017-04-25 16:00:32 +02:00
docker-compose exec postgres bash
2017-04-08 14:32:52 +02:00
pg-dump:
2017-05-16 11:59:48 +02:00
docker-compose exec postgres bash -c 'pg_dump -U postgres -d postgres -f ./latest.sql'
pg-backup:
docker-compose exec postgres bash -c 'pg_dump -U postgres -d postgres' > ~/pg-backup.sql
zip ~/pg-backup.sql.`date +"%d%m%Y-%H%M"`.zip ~/pg-backup.sql
rm ~/pg-backup.sql
2017-04-08 14:32:52 +02:00
pg-restore:
2017-05-16 11:59:48 +02:00
docker-compose exec postgres bash -c 'psql -U postgres -d postgres -f ./latest.sql'
2017-04-08 14:32:52 +02:00
pg-surefire-drop-restore-db:
2017-04-25 16:00:32 +02:00
# drop existing database, recreate it, and then restore its content from backup.
2017-09-20 12:05:58 +02:00
docker-compose exec postgres bash -c 'dropdb -h localhost -U postgres postgres'
2017-04-25 16:00:32 +02:00
docker-compose exec postgres bash -c 'createdb -h localhost -U postgres postgres'
2017-04-08 14:32:52 +02:00
make pg-restore