From 9dd908c4cc8d5daf427f1361655e90adf849967e Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Mon, 26 Feb 2024 10:53:21 -0500 Subject: [PATCH] build: mysqldump for backup/restore --- .gitignore | 6 ++++-- Makefile | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 359e2509..58269ffe 100644 --- a/.gitignore +++ b/.gitignore @@ -136,8 +136,6 @@ dmypy.json # mac Stuff .DS_Store -.dev/ - # emacs *~ .projectile @@ -150,3 +148,7 @@ docs/generated/ # private django settings enterprise_access/settings/private.py + +# devstack and assets +.dev/ +enterprise_access/assets \ No newline at end of file diff --git a/Makefile b/Makefile index 5c7b9760..729e89ad 100644 --- a/Makefile +++ b/Makefile @@ -206,11 +206,17 @@ dev.down: # Kills containers and all of their data that isn't in volumes dev.stop: # Stops containers so they can be restarted docker-compose stop -dev.backup: dev.up - docker run --rm --volumes-from enterprise_access.db -v $$(pwd)/.dev/backups:/backup debian:jessie tar zcvf /backup/mysql57.tar.gz /var/lib/mysql - -dev.restore: dev.up - docker run --rm --volumes-from enterprise_access.db -v $$(pwd)/.dev/backups:/backup debian:jessie tar zxvf /backup/mysql57.tar.gz +dev.backup: + docker-compose stop app worker + docker-compose up -d mysql80 + sleep 10 # let mysql process get fully warmed up + docker compose exec mysql80 mysqldump --all-databases > .dev/enterprise_access_all.sql + +dev.restore: + docker-compose stop app worker + docker-compose up -d mysql80 + sleep 10 # let mysql process get fully warmed up + docker compose exec -T mysql80 mysql < .dev/enterprise_access_all.sql app-shell: # Run the app shell as root docker exec -u 0 -it enterprise_access.app bash @@ -242,6 +248,12 @@ app-restart-devserver: # restart just the app Django dev server %-shell: # Run a shell, as root, on the specified service container docker exec -u 0 -it enterprise_access.$* bash +dev.static: + docker-compose exec -u 0 app python3 manage.py collectstatic --noinput + +dev.migrate: + docker-compose exec -u 0 app python manage.py migrate + github_docker_build: docker build . -f Dockerfile --target app -t openedx/enterprise-access docker build . -f Dockerfile --target newrelic -t openedx/enterprise-access:latest-newrelic