]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add more util scripts
authorrubenwardy <rw@rubenwardy.com>
Sat, 18 Jan 2020 23:20:34 +0000 (23:20 +0000)
committerrubenwardy <rw@rubenwardy.com>
Sat, 18 Jan 2020 23:20:34 +0000 (23:20 +0000)
utils/bash.sh
utils/create_migration.sh [new file with mode: 0755]
utils/db.sh [new file with mode: 0755]
utils/reload.sh
utils/run_migrations.sh [new file with mode: 0755]
utils/start.sh
utils/update.sh

index f75fc41306a0d86743399ec876482855d2ec89d6..8a3c6a0e39e6d76258bc7255703df632988ea2cf 100755 (executable)
@@ -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 (executable)
index 0000000..910344c
--- /dev/null
@@ -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 (executable)
index 0000000..f7f6af2
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Open SQL console for the database
+
+docker exec -it contentdb_db_1 sh -c "psql contentdb contentdb"
index e399515376df53b681042e3417f138424465da69..2b21e799d0471907066bfffa9cce88a887e8d62c 100755 (executable)
@@ -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 (executable)
index 0000000..ac96a95
--- /dev/null
@@ -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"
index 0fa9e795431ea83a2a0f244b78ea72be5deb1ad0..c69b676bdd238fe9e64b34df3b1b7977515db76d 100755 (executable)
@@ -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
index 97e2593008364cd329b8f1d48609cc5d6107d6cc..aeba314e83785ebe583fedf937256514e4a83f97 100755 (executable)
@@ -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