Compare commits

...

12 Commits

5 changed files with 84 additions and 21 deletions

View File

@ -66,3 +66,9 @@ OIDC_AUTH_REQUEST_EXTRA_PARAMS='{"acr_values": "eidas1"}'
LOGGING_LEVEL_HANDLERS_CONSOLE=INFO LOGGING_LEVEL_HANDLERS_CONSOLE=INFO
LOGGING_LEVEL_LOGGERS_ROOT=INFO LOGGING_LEVEL_LOGGERS_ROOT=INFO
LOGGING_LEVEL_LOGGERS_APP=INFO LOGGING_LEVEL_LOGGERS_APP=INFO
##############################################################################
# MIGRATIONS
##############################################################################
# Set to false to disable automatic migrations on backend startup
# AUTO_MIGRATIONS=true

View File

@ -20,11 +20,11 @@
* `abra app new lasuite-docs --secrets` * `abra app new lasuite-docs --secrets`
* `abra app config <app-name>` * `abra app config <app-name>`
* `abra app deploy <app-name>` * `abra app deploy <app-name>`
* `abra app cmd <app-name> backend migrate`
* Minio buckets are created automatically on first deploy. To manually trigger: `abra app cmd <app-name> minio minio_initialize`
You should then be able to visit the landing page of your app, but not yet to login. To login, you need to deploy and integrate single sign on (described below in the "Configure Authentication" section). You should then be able to visit the landing page of your app, but not yet to login. To login, you need to deploy and integrate single sign on (described below in the "Configure Authentication" section).
* Migrations run automatically on backend startup. To trigger manually: `abra app cmd <app-name> backend migrate`
* Minio buckets are created automatically on first deploy. To manually trigger: `abra app cmd <app-name> minio minio_initialize`
## Configure Authentication ## Configure Authentication

View File

@ -4,6 +4,7 @@ export ABRA_ENTRYPOINT_VERSION=v5
export NGINX_CONF_VERSION=v3 export NGINX_CONF_VERSION=v3
export PG_BACKUP_VERSION=v3 export PG_BACKUP_VERSION=v3
export MINIO_INITIALIZE_VERSION=v1 export MINIO_INITIALIZE_VERSION=v1
export MIGRATE_VERSION=v1
environment() { environment() {
# this exports all the secrets as environment variables # this exports all the secrets as environment variables
@ -11,8 +12,7 @@ environment() {
} }
migrate() { migrate() {
environment /migrate.sh
python manage.py migrate --noinput
} }
minio_initialize() { minio_initialize() {

View File

@ -49,10 +49,10 @@ x-common-env: &common-env
LOGOUT_REDIRECT_URL: LOGOUT_REDIRECT_URL:
OIDC_REDIRECT_ALLOWED_HOSTS: OIDC_REDIRECT_ALLOWED_HOSTS:
OIDC_AUTH_REQUEST_EXTRA_PARAMS: OIDC_AUTH_REQUEST_EXTRA_PARAMS:
# AI (Fixme: remove?) # AI
AI_FEATURE_ENABLED: "false" AI_FEATURE_ENABLED: "false"
AI_BASE_URL: https://openaiendpoint.com OPENAI_SDK_BASE_URL: https://openaiendpoint.com
AI_API_KEY: password OPENAI_SDK_API_KEY: password
AI_MODEL: llama AI_MODEL: llama
# Collaboration # Collaboration
COLLABORATION_API_URL: https://$DOMAIN/collaboration/api/ COLLABORATION_API_URL: https://$DOMAIN/collaboration/api/
@ -84,14 +84,14 @@ x-minio-env: &minio-env
services: services:
app: app:
image: lasuite/impress-frontend:v4.5.0 image: lasuite/impress-frontend:v5.1.0
networks: networks:
- backend - backend
deploy: deploy:
labels: labels:
- "traefik.enable=false" - "traefik.enable=false"
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}" - "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
- "coop-cloud.${STACK_NAME}.version=0.2.7+v4.5.0" - "coop-cloud.${STACK_NAME}.version=0.3.0+v5.1.0"
user: "${DOCKER_USER:-1000}" user: "${DOCKER_USER:-1000}"
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"] test: ["CMD", "curl", "-f", "http://localhost:8080"]
@ -101,11 +101,12 @@ services:
start_period: 10s start_period: 10s
backend: backend:
image: lasuite/impress-backend:v4.5.0 image: lasuite/impress-backend:v5.1.0
networks: networks:
- backend - backend
environment: environment:
<<: [*common-env, *postgres-env, *yprovider-env] <<: [*common-env, *postgres-env, *yprovider-env]
AUTO_MIGRATIONS: "${AUTO_MIGRATIONS:-true}"
healthcheck: healthcheck:
test: ["CMD", "/abra-entrypoint.sh", "python", "manage.py", "check"] test: ["CMD", "/abra-entrypoint.sh", "python", "manage.py", "check"]
interval: 15s interval: 15s
@ -114,11 +115,15 @@ services:
start_period: 10s start_period: 10s
user: "${DOCKER_USER:-1000}" user: "${DOCKER_USER:-1000}"
command: ["gunicorn", "-c", "/usr/local/etc/gunicorn/impress.py", "impress.wsgi:application"] command: ["gunicorn", "-c", "/usr/local/etc/gunicorn/impress.py", "impress.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 \"$$@\"" --
configs: configs:
- source: abra_entrypoint - source: abra_entrypoint
target: /abra-entrypoint.sh target: /abra-entrypoint.sh
mode: 0555 mode: 0555
- source: migrate
target: /migrate.sh
mode: 0555
secrets: secrets:
- django_sk - django_sk
- django_sp - django_sp
@ -131,9 +136,15 @@ services:
- email_pass - email_pass
celery: celery:
image: lasuite/impress-backend:v4.5.0 image: lasuite/impress-backend:v5.1.0
networks: networks:
- backend - backend
healthcheck:
test: ["CMD", "celery", "-A", "impress.celery_app", "inspect", "ping", "--timeout", "5"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
user: "${DOCKER_USER:-1000}" user: "${DOCKER_USER:-1000}"
command: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO"] command: ["celery", "-A", "impress.celery_app", "worker", "-l", "INFO"]
environment: environment:
@ -155,15 +166,21 @@ services:
y-provider: y-provider:
image: lasuite/impress-y-provider:v4.5.0 image: lasuite/impress-y-provider:v5.1.0
networks: networks:
- backend - backend
healthcheck:
# y-provider returns 403 on unauthenticated requests; wget exit 4 = network error (server down), anything else = server is responding
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:4444/ 2>/dev/null; test $$? -ne 4"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
environment: *yprovider-env environment: *yprovider-env
user: "${DOCKER_USER:-1000}" user: "${DOCKER_USER:-1000}"
entrypoint: > entrypoint: >
sh -c "export Y_PROVIDER_API_KEY=\"$$(cat /run/secrets/y_api_key)\" && exec /usr/local/bin/entrypoint \"$$@\"" -- sh -c "export Y_PROVIDER_API_KEY=\"$$(cat /run/secrets/y_api_key)\" && exec /usr/local/bin/entrypoint \"$$@\"" --
command: ["yarn", "start"] command: ["yarn", "start"]
# NOTE: healthcheck - `wget` is available in the container, but `wget http://localhost:4444` gives a 403
secrets: secrets:
- y_api_key - y_api_key
@ -195,7 +212,12 @@ services:
- postgres_p - postgres_p
redis: redis:
image: redis:8 image: redis:8.2.6
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 15s
timeout: 5s
retries: 3
networks: networks:
- backend - backend
@ -230,7 +252,13 @@ services:
- minio_ru - minio_ru
web: web:
image: nginx:1.29 image: nginx:1.30.0
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8083"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
configs: configs:
- source: nginx_conf - source: nginx_conf
target: /etc/nginx/conf.d/default.conf target: /etc/nginx/conf.d/default.conf
@ -275,6 +303,9 @@ configs:
minio_initialize: minio_initialize:
name: ${STACK_NAME}_minio_initialize_${MINIO_INITIALIZE_VERSION} name: ${STACK_NAME}_minio_initialize_${MINIO_INITIALIZE_VERSION}
file: minio-initialize.sh file: minio-initialize.sh
migrate:
name: ${STACK_NAME}_migrate_${MIGRATE_VERSION}
file: migrate.sh
secrets: secrets:
django_sk: django_sk:

26
migrate.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
set -e
# Load secrets into environment
source /abra-entrypoint.sh -e
# Wait for database to be ready (up to 30 seconds)
i=0
while ! python manage.py check --database default 2>/dev/null; do
i=$((i+1))
if [ "$i" -ge 30 ]; then
echo "migrate: timed out waiting for database" >&2
exit 1
fi
sleep 1
done
# Idempotent: skip if no pending migrations
if python manage.py migrate --check > /dev/null 2>&1; then
echo "migrate: no pending migrations, skipping"
exit 0
fi
echo "migrate: applying pending migrations..."
python manage.py migrate --noinput
echo "migrate: done"