mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Make util scripts work on both docker-compose v1 and v2
This commit is contained in:
parent
8e312c4bcc
commit
4ef3aae193
@ -2,4 +2,7 @@
|
||||
|
||||
# Open SSH to app instance
|
||||
|
||||
docker exec -it contentdb_app_1 bash
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec -it "$(container app)" bash
|
||||
|
15
utils/common.sh
Normal file → Executable file
15
utils/common.sh
Normal file → Executable file
@ -1,3 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
docker_compose_version=$(docker-compose --version --short)
|
||||
docker_compose_major=${docker_compose_version:0:1}
|
||||
|
||||
if [[ $docker_compose_major == "2" ]]; then
|
||||
sep="-"
|
||||
else
|
||||
sep="_"
|
||||
fi
|
||||
|
||||
container() {
|
||||
contentdb-$1
|
||||
echo "contentdb${sep}$1${sep}1"
|
||||
}
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
# Create a database migration, and copy it back to the host.
|
||||
|
||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate"
|
||||
docker exec -u root contentdb_app_1 sh -c "cp /home/cdb/migrations/versions/* /source/migrations/versions/"
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec "$(container app)" sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db migrate"
|
||||
docker exec -u root "$(container app)" sh -c "cp /home/cdb/migrations/versions/* /source/migrations/versions/"
|
||||
|
||||
USER=$(whoami)
|
||||
sudo chown -R $USER:$USER migrations/versions
|
||||
sudo chown -R "$USER:$USER" migrations/versions
|
||||
|
@ -2,4 +2,7 @@
|
||||
|
||||
# Open SQL console for the database
|
||||
|
||||
docker exec -it contentdb_db_1 psql contentdb contentdb
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec -it "$(container db)" psql contentdb contentdb
|
||||
|
@ -2,4 +2,7 @@
|
||||
|
||||
# Create a database migration, and copy it back to the host.
|
||||
|
||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db downgrade"
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec "$(container app)" sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db downgrade"
|
||||
|
@ -2,4 +2,7 @@
|
||||
|
||||
# Hot/live reload - only works in debug mode
|
||||
|
||||
docker exec contentdb_app_1 sh -c "cp -r /source/* ."
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec "$(container app)" sh -c "cp -r /source/* ."
|
||||
|
@ -3,6 +3,7 @@
|
||||
# Restores backup
|
||||
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: ./utils/restore_bk.sh path/to/backup.sql"
|
||||
@ -24,4 +25,4 @@ if [[ "$BKFILE" == *.gpg ]]; then
|
||||
fi
|
||||
|
||||
echo "Importing backup from $BKFILE"
|
||||
cat $BKFILE | docker exec -i contentdb_db_1 psql contentdb contentdb
|
||||
cat $BKFILE | docker exec -i "$(container db)" psql contentdb contentdb
|
||||
|
@ -2,5 +2,8 @@
|
||||
|
||||
# Run all pending migrations
|
||||
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
./utils/reload.sh
|
||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db upgrade"
|
||||
docker exec "$(container app)" sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py flask db upgrade"
|
||||
|
@ -1,3 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py python -m pytest app/tests/ --disable-warnings"
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec "$(container app)" sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py python -m pytest app/tests/ --disable-warnings"
|
||||
|
@ -1,3 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
docker exec contentdb_app_1 sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py python -m pytest app/tests/ --cov=app --disable-warnings"
|
||||
set -e
|
||||
. "${BASH_SOURCE%/*}/common.sh"
|
||||
|
||||
docker exec "$(container app)" sh -c "FLASK_CONFIG=../config.cfg FLASK_APP=app/__init__.py python -m pytest app/tests/ --cov=app --disable-warnings"
|
||||
|
@ -5,6 +5,8 @@
|
||||
# This is for production use. See reload.sh for debug mode hot/live reloading.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
docker-compose build app
|
||||
docker-compose build worker
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pybabel extract -F babel.cfg -k lazy_gettext -o translations/messages.pot .
|
||||
pybabel update -i translations/messages.pot -d translations --no-fuzzy-matching
|
||||
|
Loading…
Reference in New Issue
Block a user