run migrations automatically on backend startup (AUTO_MIGRATIONS)

Add a migrate.sh config (ported from lasuite-docs) that the backend
entrypoint runs when AUTO_MIGRATIONS=true (default). It loads secrets,
waits for the DB, and idempotently applies pending migrations via
'migrate --check' then 'migrate --noinput'. The manual 'abra app cmd
backend migrate' now delegates to the same script.
This commit is contained in:
notplants
2026-06-23 19:13:39 +00:00
committed by notplants
parent d3c3682936
commit 0b64135f98
5 changed files with 45 additions and 4 deletions

View File

@ -118,9 +118,11 @@ services:
user: ${DOCKER_USER:-1000}
image: lasuite/drive-backend:v0.19.0
command: [ "gunicorn", "-c", "/usr/local/etc/gunicorn/drive.py", "drive.wsgi:application" ]
entrypoint: [ "/abra-entrypoint.sh", "/usr/local/bin/entrypoint" ]
entrypoint: >
sh -c "if [ \"$$AUTO_MIGRATIONS\" = \"true\" ]; then /migrate.sh; fi && exec /abra-entrypoint.sh /usr/local/bin/entrypoint \"$$@\"" --
environment:
<<: [ *common-env, *postgres-env ]
AUTO_MIGRATIONS: "${AUTO_MIGRATIONS:-true}"
networks:
- backend
depends_on:
@ -129,6 +131,9 @@ services:
- source: abra_entrypoint
target: /abra-entrypoint.sh
mode: 0555
- source: migrate
target: /migrate.sh
mode: 0555
secrets:
- django_sk
- django_sp
@ -405,6 +410,9 @@ configs:
abra_entrypoint:
name: ${STACK_NAME}_entrypoint_${ABRA_ENTRYPOINT_VERSION}
file: abra-entrypoint.sh
migrate:
name: ${STACK_NAME}_migrate_${MIGRATE_VERSION}
file: migrate.sh
onlyoffice_conf:
name: ${STACK_NAME}_onlyoffice_conf_${ONLYOFFICE_CONF_VERSION}
file: onlyoffice-config.json.tmpl