aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/bash.sh2
-rwxr-xr-xutils/create_migration.sh9
-rwxr-xr-xutils/db.sh5
-rwxr-xr-xutils/reload.sh2
-rwxr-xr-xutils/run_migrations.sh5
-rwxr-xr-xutils/start.sh2
-rwxr-xr-xutils/update.sh1
7 files changed, 26 insertions, 0 deletions
diff --git a/utils/bash.sh b/utils/bash.sh
index f75fc41..8a3c6a0 100755
--- a/utils/bash.sh
+++ b/utils/bash.sh
@@ -1,3 +1,5 @@
#!/bin/bash
+# Open SSH to app instance
+
docker exec -it contentdb_app_1 bash
diff --git a/utils/create_migration.sh b/utils/create_migration.sh
new file mode 100755
index 0000000..910344c
--- /dev/null
+++ b/utils/create_migration.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# Create a database migration, and copy it back to the host.
+
+docker exec -it contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate"
+docker exec -u root -it contentdb_app_1 sh -c "cp /home/cdb/migrations/versions/* /source/migrations/versions/"
+
+USER=$(whoami)
+sudo chown -R $USER:$USER migrations/versions
diff --git a/utils/db.sh b/utils/db.sh
new file mode 100755
index 0000000..f7f6af2
--- /dev/null
+++ b/utils/db.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Open SQL console for the database
+
+docker exec -it contentdb_db_1 sh -c "psql contentdb contentdb"
diff --git a/utils/reload.sh b/utils/reload.sh
index e399515..2b21e79 100755
--- a/utils/reload.sh
+++ b/utils/reload.sh
@@ -1,3 +1,5 @@
#!/bin/bash
+# Hot/live reload - only works in debug mode
+
docker exec -it contentdb_app_1 sh -c "cp -r /source/* ."
diff --git a/utils/run_migrations.sh b/utils/run_migrations.sh
new file mode 100755
index 0000000..ac96a95
--- /dev/null
+++ b/utils/run_migrations.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Run all pending migrations
+
+docker exec -it contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db update"
diff --git a/utils/start.sh b/utils/start.sh
index 0fa9e79..c69b676 100755
--- a/utils/start.sh
+++ b/utils/start.sh
@@ -2,6 +2,8 @@
#
# Call from a docker host to build and start CDB.
+# This is really only for production mode, for debugging it's better to use
+# docker-compose directly: docker-compose up --build
#
sudo docker-compose up --build -d --scale worker=2
diff --git a/utils/update.sh b/utils/update.sh
index 97e2593..aeba314 100755
--- a/utils/update.sh
+++ b/utils/update.sh
@@ -2,6 +2,7 @@
#
# Call from a docker host to rebuild and update running instances of CDB.
+# This is for production use. See reload.sh for debug mode hot/live reloading.
#
sudo docker-compose build app