Docker support in Makefile
This commit is contained in:
parent
03d053a626
commit
0c4d9b41f5
2 changed files with 81 additions and 10 deletions
77
Makefile
Normal file
77
Makefile
Normal file
|
@ -0,0 +1,77 @@
|
|||
export COMPOSE_FILE=./docker-compose.yml
|
||||
export COMPOSE_PROJECT_NAME=publichealth
|
||||
|
||||
default: build
|
||||
|
||||
build-cached:
|
||||
docker-compose build
|
||||
|
||||
build:
|
||||
docker-compose build --no-cache
|
||||
|
||||
run:
|
||||
docker-compose stop web # for restart cases, when already running
|
||||
docker-compose up
|
||||
|
||||
run-detached:
|
||||
docker-compose up -d
|
||||
|
||||
django-restart-detached:
|
||||
docker-compose stop web
|
||||
docker-compose up -d web
|
||||
|
||||
stop:
|
||||
docker-compose stop
|
||||
|
||||
migrate:
|
||||
docker-compose exec web ./manage.py migrate
|
||||
|
||||
migrations:
|
||||
docker-compose exec web ./manage.py makemigrations
|
||||
|
||||
apply-migrations: migrations migrate
|
||||
|
||||
setup:
|
||||
docker-compose exec web ./manage.py migrate
|
||||
docker-compose exec web ./manage.py createsuperuser
|
||||
docker-compose exec web ./manage.py compress
|
||||
docker-compose exec web ./manage.py collectstatic
|
||||
|
||||
release:
|
||||
docker-compose stop web
|
||||
docker-compose kill web
|
||||
docker-compose build web
|
||||
docker-compose up -d web
|
||||
|
||||
django-exec-bash:
|
||||
# execute bash in the currently running container
|
||||
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:
|
||||
docker-compose logs -f --tail=500
|
||||
|
||||
pg-run-detached:
|
||||
# start pg service
|
||||
docker-compose up -d pg_database
|
||||
|
||||
pg-exec:
|
||||
docker-compose exec pg_database bash
|
||||
|
||||
pg-dump:
|
||||
docker-compose exec pg_database bash -c 'pg_dump -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -f ./dumps/latest.sql'
|
||||
|
||||
pg-restore:
|
||||
docker-compose exec pg_database bash -c 'psql -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -f ./dumps/latest.sql'
|
||||
|
||||
pg-surefire-drop-restore-db:
|
||||
# drop existing database, recreate it, and then restore its content from backup.
|
||||
-docker-compose exec pg_database bash -c 'dropdb -h localhost -U "$$POSTGRES_USER" "$$POSTGRES_DB"'
|
||||
docker-compose exec pg_database bash -c 'createdb -h localhost -U "$$POSTGRES_USER" "$$POSTGRES_DB"'
|
||||
make pg-restore
|
14
README.md
14
README.md
|
@ -60,14 +60,8 @@ Now access the admin panel with the user account you created earlier: http://loc
|
|||
|
||||
## Production notes
|
||||
|
||||
We suggest using Docker or [Dokku](http://dokku.viewdocs.io/) for automated deployment.
|
||||
We suggest using Docker or [Dokku](http://dokku.viewdocs.io/) for automated deployment. There is a Makefile to help set up and manage the instance.
|
||||
|
||||
```
|
||||
docker-compose run web python manage.py migrate
|
||||
... createsuperuser
|
||||
... compress
|
||||
... collectstatic
|
||||
|
||||
docker-compose build web
|
||||
docker-compose up -d
|
||||
```
|
||||
- Initial setup: `make setup`
|
||||
- Startup: `make run-detached`
|
||||
- Release: `make release`
|
||||
|
|
Loading…
Add table
Reference in a new issue