From 3f99bbabcce6af3b6ae77bc3af1b49a3051ca7d4 Mon Sep 17 00:00:00 2001 From: brooke Date: Wed, 18 Jun 2025 17:10:12 -0400 Subject: [PATCH] remove init script in favor of an abra.sh function, add liberaforms container to proxy and update readme. --- .env.sample | 2 +- README.md | 4 ++-- abra.sh | 40 ++++++++++++++++++++++++++++++++++++++++ compose.yml | 20 +++++--------------- init.sh.tmpl | 34 ---------------------------------- 5 files changed, 48 insertions(+), 52 deletions(-) delete mode 100644 init.sh.tmpl diff --git a/.env.sample b/.env.sample index 7d3805b..884cc01 100644 --- a/.env.sample +++ b/.env.sample @@ -17,7 +17,7 @@ DEFAULT_TIMEZONE="America/New_York" ENABLE_RSS_FEED=True ENABLE_PROMETHEUS_METRICS=False -#GUNICORN_WORKERS= # Advanced option based on the specs of your server, defaults to 6 +#GUNICORN_WORKERS= # Advanced option based on the specs of your server, defaults to 3 #ALERT_MAILS = ["your_email_address", "another_email_address"] # Optional. Recieve Internal Server 500 errors. Good for debugging. diff --git a/README.md b/README.md index 2ed344b..31a3a5a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ * **Category**: Apps * **Status**: wip -* **Image**: [`liberaforms`](https://hub.docker.com/r/liberaforms), 4, upstream +* **Image**: [`liberaforms`](https://fung.uy/mycosystems/-/packages/container/liberaforms/), 1 * **Healthcheck**: Yes * **Backups**: No * **Email**: 1 @@ -20,6 +20,6 @@ * `abra app new liberaforms --secrets` * `abra app config ` * `abra app deploy ` -* `abra app run app /init.sh` [Create tables](https://gitlab.com/liberaforms/liberaforms/-/blob/main/docs/docker.md?ref_type=heads#create-the-database) in pgsql database +* `abra app cmd forms.fung.uy app create_database` [Create tables](https://gitlab.com/liberaforms/liberaforms/-/blob/main/docs/docker.md?ref_type=heads#create-the-database) For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech). diff --git a/abra.sh b/abra.sh index fc4a203..419452f 100644 --- a/abra.sh +++ b/abra.sh @@ -1,2 +1,42 @@ +#!/bin/bash + export ENTRYPOINT_VERSION=v2 export INIT_VERSION=v1 + +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + + local val="$def" + + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(<"${!fileVar}")" + fi + + export "$var"="$val" + unset "$fileVar" +} + +setup_db() { + file_env "DB_PASSWORD" + file_env "CRYPTO_KEY" + file_env "SECRET_KEY" + file_env "LDAP_BIND_PASSWORD" + + echo "Creating tables..." + flask database create-tables && flask db stamp + if [ $? -ne 0 ]; then + echo -e "\033[0;31m\nDatabase failed to initialize please open an issue at https://git.coopcloud.tech/coop-cloud/liberaforms/issues\n" + return 1 + fi + + echo "Database setup complete. <3" +} diff --git a/compose.yml b/compose.yml index d2f5425..d510f7b 100644 --- a/compose.yml +++ b/compose.yml @@ -9,10 +9,8 @@ services: - source: entrypoint mode: 0555 target: /custom-entrypoint.sh - - source: init - mode: 0555 - target: /init.sh entrypoint: /custom-entrypoint.sh + command: "/usr/bin/supervisord -n" environment: ENABLE_LDAP: "False" FLASK_DEBUG: "False" @@ -29,9 +27,8 @@ services: SESSION_TYPE: "filesystem" LOG_LEVEL: INFO LOG_DIR: /app/logs - GUNICORN_WORKERS: ${GUNICORN_WORKERS:-6} + GUNICORN_WORKERS: ${GUNICORN_WORKERS:-3} volumes: - - app - uploads:/app/uploads - log:/app/logs secrets: @@ -40,12 +37,13 @@ services: - crypto_key networks: - internal + - proxy deploy: labels: - - "coop-cloud.${STACK_NAME}.version=" + - "coop-cloud.${STACK_NAME}.version=wip" - "traefik.enable=true" - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=5000" - - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" @@ -93,11 +91,3 @@ configs: name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION} file: entrypoint.sh.tmpl template_driver: golang - init: - name: ${STACK_NAME}_init_${INIT_VERSION} - file: init.sh.tmpl - template_driver: golang - nginx_conf: - name: ${STACK_NAME}_nginx_conf_${NGINX_CONF_VERSION} - file: nginx.conf.tmpl - template_driver: golang diff --git a/init.sh.tmpl b/init.sh.tmpl deleted file mode 100644 index a347a16..0000000 --- a/init.sh.tmpl +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -file_env() { - local var="$1" - local fileVar="${var}_FILE" - local def="${2:-}" - - if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then - echo >&2 "error: both $var and $fileVar are set (but are exclusive)" - exit 1 - fi - - local val="$def" - - if [ "${!var:-}" ]; then - val="${!var}" - elif [ "${!fileVar:-}" ]; then - val="$(< "${!fileVar}")" - fi - - export "$var"="$val" - unset "$fileVar" -} - -file_env "DB_PASSWORD" -file_env "CRYPTO_KEY" -file_env "SECRET_KEY" -file_env "LDAP_BIND_PASSWORD" - -flask database create --docker-container db - -flask database create-tables