From 293dd80e535675e6ac67ca0a6d0d0e9514d513bf Mon Sep 17 00:00:00 2001 From: notplants Date: Sat, 1 Nov 2025 16:26:05 -0400 Subject: [PATCH] Attempt at universal abra wrapper --- abra.sh | 2 +- compose.yml | 35 ++++++++++++++++++++++++----------- entrypoint.sh | 38 ++++++++++++++++++++++---------------- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/abra.sh b/abra.sh index 80e73ce..4dc4af7 100755 --- a/abra.sh +++ b/abra.sh @@ -1,6 +1,6 @@ # Set any config versions here # Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs -export ABRA_LASUITE_ENTRYPOINT_VERSION=v2 +export ABRA_ENTRYPOINT_VERSION=v3 export NGINX_CONF_VERSION=v2 export PG_BACKUP_VERSION=v3 diff --git a/compose.yml b/compose.yml index eabb634..87f27da 100644 --- a/compose.yml +++ b/compose.yml @@ -115,10 +115,11 @@ services: retries: 20 start_period: 10s command: ["gunicorn", "-c", "/usr/local/etc/gunicorn/impress.py", "impress.wsgi:application"] - entrypoint: /abra-lasuite-entrypoint.sh + # entrypoint: "/abra-entrypoint.sh" + entrypoint: ["/abra-entrypoint.sh", "/usr/local/bin/entrypoint"] configs: - - source: abra_lasuite_entrypoint - target: /abra-lasuite-entrypoint.sh + - source: abra_entrypoint + target: /abra-entrypoint.sh mode: 0555 secrets: - django_secret_key @@ -136,10 +137,10 @@ services: command: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO"] environment: <<: [*common-env, *postgres-env, *yprovider-env] - entrypoint: /abra-lasuite-entrypoint.sh + entrypoint: ["/abra-entrypoint.sh", "/usr/local/bin/entrypoint"] configs: - - source: abra_lasuite_entrypoint - target: /abra-lasuite-entrypoint.sh + - source: abra_entrypoint + target: /abra-entrypoint.sh mode: 0555 secrets: - django_secret_key @@ -156,6 +157,12 @@ services: networks: - backend environment: *yprovider-env + command: ["yarn", "start"] + entrypoint: ["/abra-entrypoint.sh", "/usr/local/bin/entrypoint"] + configs: + - source: abra_entrypoint + target: /abra-entrypoint.sh + mode: 0555 # NOTE: healthcheck - `wget` is available in the container, but `wget http://localhost:4444` gives a 403 db: @@ -172,6 +179,8 @@ services: PGDATA: var/lib/postgresql/data/pgdata volumes: - postgres:/var/lib/postgresql/data/pgdata + command: ["postgres"] + entrypoint: ["/abra-entrypoint.sh", "docker-entrypoint.sh"] deploy: labels: backupbot.backup: "${ENABLE_BACKUPS:-true}" @@ -182,6 +191,9 @@ services: - source: pg_backup target: /pg_backup.sh mode: 0555 + - source: abra_entrypoint + target: /abra-entrypoint.sh + mode: 0555 redis: image: redis:8 @@ -219,15 +231,16 @@ services: networks: - backend command: minio server /data + entrypoint: ["/abra-entrypoint.sh", "/usr/bin/docker-entrypoint.sh"] volumes: - minio:/data deploy: labels: backupbot.backup: "${ENABLE_BACKUPS:-true}" - entrypoint: /abra-lasuite-entrypoint.sh + entrypoint: /abra-entrypoint.sh configs: - - source: abra_lasuite_entrypoint - target: /abra-lasuite-entrypoint.sh + - source: abra_entrypoint + target: /abra-entrypoint.sh mode: 0555 secrets: - django_secret_key @@ -273,8 +286,8 @@ configs: pg_backup: name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION} file: pg_backup.sh - abra_lasuite_entrypoint: - name: ${STACK_NAME}_entrypoint_${ABRA_LASUITE_ENTRYPOINT_VERSION} + abra_entrypoint: + name: ${STACK_NAME}_entrypoint_${ABRA_ENTRYPOINT_VERSION} file: entrypoint.sh secrets: diff --git a/entrypoint.sh b/entrypoint.sh index 4fbd33f..39ac0c8 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,20 +1,26 @@ #!/bin/sh +set -e -DJANGO_SECRET_KEY="$(cat /run/secrets/django_secret_key)" -OIDC_RP_CLIENT_SECRET="$(cat /run/secrets/oidc_rp_client_secret)" -DJANGO_SUPERUSER_PASSWORD="$(cat /run/secrets/django_superuser_password)" -COLLABORATION_SERVER_SECRET="$(cat /run/secrets/collaboration_server_secret)" -POSTGRES_PASSWORD="$(cat /run/secrets/postgres_password)" -DB_PASSWORD="$(cat /run/secrets/db_password)" -MINIO_ROOT_PASSWORD="$(cat /run/secrets/minio_root_password)" +echo "++ running new entrypoint" +ORIGINAL_ENTRYPOINT="$1" +shift -export DJANGO_SECRET_KEY -export OIDC_RP_CLIENT_SECRET -export DJANGO_SUPERUSER_PASSWORD -export COLLABORATION_SERVER_SECRET -export POSTGRES_PASSWORD -export DB_PASSWORD -export MINIO_ROOT_PASSWORD +echo "++ original entrypoint: ${ORIGINAL_ENTRYPOINT}" -# Execute the actual command (from command: in compose.yml) -exec "$@" +# --- Load secrets into environment variables --- +if [ -d /run/secrets ]; then + for secret_file in /run/secrets/*; do + echo "++ loading secret: ${secret_file}" + var_name=$(basename "$secret_file" | tr '[:lower:]' '[:upper:]') + export "$var_name"="$(cat "$secret_file")" + done +fi + +echo "++ command: ${@}" + +# --- Execute the original entrypoint and command --- +if [ -n "$ORIGINAL_ENTRYPOINT" ] && [ "$ORIGINAL_ENTRYPOINT" != "null" ]; then + exec "$ORIGINAL_ENTRYPOINT" "$@" +else + exec "$@" +fi