Compare commits
20 Commits
0.1.0+11.1
...
fixed_vers
| Author | SHA1 | Date | |
|---|---|---|---|
| 905d9bd232 | |||
| 9d753c1b10 | |||
| 48531310dc | |||
| 9006e45350 | |||
| 5fd5528342 | |||
| b4d1ac9a2d | |||
| e475f066d2 | |||
| 126bec5ef7 | |||
| 0d7f132f22 | |||
| c5e33cf8bf | |||
| 3c818aaf6d | |||
| 5b1366eb7b | |||
| 71b43a0d00 | |||
| 0f3a6120a1 | |||
| 93e34e1077 | |||
| 818c92b3e2 | |||
| ce435071b8 | |||
| 1c5ae31ddd | |||
| a0284c5efc | |||
| 9baac5a574 |
40
.env.sample
40
.env.sample
@ -11,6 +11,44 @@ DOMAIN=directus.example.com
|
||||
|
||||
LETS_ENCRYPT_ENV=production
|
||||
|
||||
COMPOSE_FILE="compose.yml"
|
||||
|
||||
ENABLE_BACKUPS=true
|
||||
|
||||
ADMIN_EMAIL=mail@example.com
|
||||
ADMIN_EMAIL=mail@example.com
|
||||
|
||||
# if you don't use smtp, sendmail is used
|
||||
# COMPOSE_FILE="$COMPOSE_FILE:compose.smtp.yml"
|
||||
# SECRET_SMTP_PASSWORD_VERSION=v1
|
||||
# EMAIL_FROM=noreply@example.com
|
||||
# EMAIL_SMTP_USER=
|
||||
# EMAIL_SMTP_HOST=mailhost.com
|
||||
# EMAIL_SMTP_PORT=465
|
||||
# EMAIL_SMTP_SECURE=true
|
||||
|
||||
|
||||
## SSO (via OpenId)
|
||||
|
||||
# Details about env-vars, the once below are necessary, others can be used as well:
|
||||
# https://directus.io/docs/configuration/auth-sso#openid-connect
|
||||
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.oidc.yml"
|
||||
#SECRET_OIDC_SECRET_VERSION=v1
|
||||
|
||||
#AUTH_DISABLE_DEFAULT="false"
|
||||
#AUTH_SSO_LABEL="Single-Sign On"
|
||||
#AUTH_SSO_CLIENT_ID="<your-client-id>"
|
||||
#AUTH_SSO_ISSUER_URL="<your-.wellknown-issuer-url"
|
||||
#AUTH_SSO_ALLOW_PUBLIC_REGISTRATION="true"
|
||||
#AUTH_SSO_DEFAULT_ROLE_ID="<UUID-of-a-user-role>"
|
||||
#AUTH_SSO_SYNC_USER_INFO="true"
|
||||
#AUTH_SSO_SCOPE="openid profile email"
|
||||
#AUTH_SSO_ROLE_MAPPING='json:{"sso_role1": "directus-role-uuid","sso_role2": "directus-role-uuid"}'
|
||||
|
||||
# https://directus.io/docs/configuration/auth-sso
|
||||
# if you need more/other provider(s), consult docs on how to override compose.yml:
|
||||
# https://docs.coopcloud.tech/operators/handbook/#how-can-i-modifyoverride-the-composeyml-file
|
||||
|
||||
## Custom Image Version
|
||||
# COMPOSE_FILE="$COMPOSE_FILE:compose.customversion.yml"
|
||||
# IMAGE_VERSION=11.13.1
|
||||
64
README.md
64
README.md
@ -1,24 +1,78 @@
|
||||
# directus
|
||||
|
||||
> Directus is a (headless) CMS / backend system for managing data and creating APIs.
|
||||
> Directus is an open-source headless CMS & API for managing agnostic content.
|
||||
|
||||
<!-- metadata -->
|
||||
|
||||
* **Maintainer**: [@val](https://git.coopcloud.tech/val)
|
||||
* **Status**: `testing`
|
||||
* **Category**: Apps
|
||||
* **Status**: 0
|
||||
* **Image**: [`directus`](https://hub.docker.com/r/directus), 4, upstream
|
||||
* **Healthcheck**: Yes
|
||||
* **Backups**: Yes
|
||||
* **Email**: No
|
||||
* **Email**: Yes
|
||||
* **Tests**: No
|
||||
* **SSO**: No
|
||||
* **SSO**: Yes
|
||||
|
||||
<!-- endmetadata -->
|
||||
|
||||
## Quick start
|
||||
|
||||
* `abra app new directus --secrets`
|
||||
* `abra app new directus`
|
||||
* `abra app secret generate <app-name> --all`
|
||||
* `abra app config <app-name>`
|
||||
* `abra app deploy <app-name>`
|
||||
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
|
||||
|
||||
## Additional configs
|
||||
|
||||
### smtp
|
||||
By default `sendmail` is configured. To use SMTP uncomment the respective section in your .env-file and insert the smtp-secret:
|
||||
* `abra app secret insert <app-name> smtp_password v1 <your-smtp-password>`
|
||||
|
||||
By this you make usage of [compose.smtp.yml](compose.smtp.yml)
|
||||
|
||||
### sso (oidc)
|
||||
The config of one oidc-provider is prepared. Just uncomment an fill in the respective part in .env-file. By this you make usage of [compose.oidc.yml](compose.oidc.yml). If you need further providers, consider [adding a custom compose-file](https://docs.coopcloud.tech/operators/handbook/#how-can-i-modifyoverride-the-composeyml-file) containing the necessary env-vars as indicated in the directus' docs.
|
||||
|
||||
|
||||
### using the directus' cli for templates
|
||||
In [abra.sh](abra.sh) you find some commands you can run with `abra app cmd` for usage of directus' cli (e.g.) for exporting and importing a schema / template / data ...
|
||||
|
||||
|
||||
### setting custom .env-vars / secrets
|
||||
Automation in directus is a mighty tool to customize your CMS. If you need to pass a custom env-var or secret, you can do so by [adding a custom compose-file](https://docs.coopcloud.tech/operators/handbook/#how-can-i-modifyoverride-the-composeyml-file).
|
||||
|
||||
This is a working example. Make sure you add all your env-vars, that you want to be able to access in flows to the comma separated env-var `FLOWS_ENV_ALLOW_LIST` like explained [here](https://directus.io/docs/configuration/flows).
|
||||
|
||||
`directus.compose.customenv.yml`
|
||||
```
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
FLOWS_ENV_ALLOW_LIST: "API_USER,API_TOKEN"
|
||||
API_USER: "MyApiUser"
|
||||
API_TOKEN_FILE: /run/secrets/api_token
|
||||
|
||||
secrets:
|
||||
- api_token
|
||||
|
||||
|
||||
secrets:
|
||||
api_token:
|
||||
name: ${STACK_NAME}_oidc_secret_${SECRET_API_TOKEN_VERSION}
|
||||
external: true
|
||||
```
|
||||
|
||||
in your `env-file` you would add:
|
||||
|
||||
```
|
||||
# custom secrets
|
||||
COMPOSE_FILE="compose.yml:../../servers/<yourserver>/directus.compose.customenv.yml"
|
||||
|
||||
SECRET_API_TOKEN_VERSION=v1
|
||||
```
|
||||
|
||||
and then redeploy: `abra app deploy -f <app-name>`
|
||||
63
abra.sh
63
abra.sh
@ -1,4 +1,63 @@
|
||||
# Set any config versions here
|
||||
# Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs
|
||||
export DIRECTUS_ENTRYPOINT_VERSION=v1
|
||||
export PG_BACKUP_VERSION=v1
|
||||
export DIRECTUS_ENTRYPOINT_VERSION=v5
|
||||
export PG_BACKUP_VERSION=v1
|
||||
|
||||
# essentially a wrapper for directus-template-cli apply:
|
||||
# https://github.com/directus-labs/directus-template-cli
|
||||
apply_community_template () {
|
||||
echo "This will apply one of the community templates to your directus installation."
|
||||
echo "Checkout existing templates here: https://github.com/directus-labs/directus-templates"
|
||||
echo "\"CMS\" is proably what you want, there exist others, e.g. \"Simple CRM\", for others checkout github-repo and look in the package.json for \"templateName\""
|
||||
|
||||
|
||||
echo -n "Enter template name (e.g. \"CMS\"): "
|
||||
read template
|
||||
|
||||
if [ -z "$template" ]; then
|
||||
echo "You need to define a template" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "\n will try to apply template \"$template\". "
|
||||
read -p "Proceed? (y/n): " proceed
|
||||
|
||||
|
||||
if [ "$proceed" != "y" ]; then
|
||||
echo "Aborting."
|
||||
return 1
|
||||
fi
|
||||
|
||||
npx --yes directus-template-cli@latest apply -p \
|
||||
--directusUrl=https://$DOMAIN \
|
||||
--userEmail=$ADMIN_EMAIL \
|
||||
--userPassword=$(cat /var/run/secrets/admin_password) \
|
||||
--templateLocation="$template" \
|
||||
--templateType="community"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# run locally!
|
||||
# essentially a wrapper for directus-template-cli extract:
|
||||
# https://github.com/directus-labs/directus-template-cli
|
||||
extract_template (){
|
||||
TEMPLATE_LOCATION="./directus-template"
|
||||
TEMPLATE_NAME="directus-template"
|
||||
|
||||
echo "script extracts your current directus settings (includes data!) and saves it with the template name \"$TEMPLATE_NAME\" to the folder \"$TEMPLATE_LOCATION\""
|
||||
|
||||
ADMIN_PASSWORD=$(abra app run -t $DOMAIN app -- cat /var/run/secrets/admin_password)
|
||||
npx --yes directus-template-cli@latest extract -p \
|
||||
--directusUrl=https://$DOMAIN \
|
||||
--userEmail=$ADMIN_EMAIL \
|
||||
--userPassword=$ADMIN_PASSWORD \
|
||||
--templateLocation="$TEMPLATE_LOCATION" \
|
||||
--templateName="$TEMPLATE_NAME"
|
||||
|
||||
ADMIN_PASSWORD=""
|
||||
TEMPLATE_LOCATION=""
|
||||
TEMPLATE_NAME=""
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
3
compose.customversion.yml
Normal file
3
compose.customversion.yml
Normal file
@ -0,0 +1,3 @@
|
||||
services:
|
||||
app:
|
||||
image: directus/directus:${IMAGE_VERSION}
|
||||
31
compose.oidc.yml
Normal file
31
compose.oidc.yml
Normal file
@ -0,0 +1,31 @@
|
||||
---
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
AUTH_PROVIDERS: "sso"
|
||||
AUTH_DISABLE_DEFAULT: "${AUTH_DISABLE_DEFAULT:-false}"
|
||||
AUTH_SSO_DRIVER: "openid"
|
||||
AUTH_SSO_CLIENT_ID: ${AUTH_SSO_CLIENT_ID}
|
||||
AUTH_SSO_CLIENT_SECRET_FILE: /run/secrets/oidc_secret
|
||||
AUTH_SSO_ISSUER_URL: ${AUTH_SSO_ISSUER_URL}
|
||||
AUTH_SSO_SCOPE: ${AUTH_SSO_SCOPE:-"openid profile email"}
|
||||
AUTH_SSO_IDENTIFIER_KEY: ${AUTH_SSO_IDENTIFIER_KEY}
|
||||
AUTH_SSO_ALLOW_PUBLIC_REGISTRATION: ${AUTH_SSO_ALLOW_PUBLIC_REGISTRATION:-false}
|
||||
AUTH_SSO_REQUIRE_VERIFIED_EMAIL: ${AUTH_SSO_REQUIRE_VERIFIED_EMAIL:-false}
|
||||
AUTH_SSO_DEFAULT_ROLE_ID: ${AUTH_SSO_DEFAULT_ROLE_ID}
|
||||
AUTH_SSO_SYNC_USER_INFO: ${AUTH_SSO_SYNC_USER_INFO:-true}
|
||||
AUTH_SSO_ROLE_MAPPING: ${AUTH_SSO_ROLE_MAPPING}
|
||||
AUTH_SSO_GROUP_CLAIM_NAME: ${AUTH_SSO_GROUP_CLAIM_NAME:-groups}
|
||||
AUTH_SSO_ICON: ${AUTH_SSO_ICON:-account_circle}
|
||||
AUTH_SSO_LABEL: ${AUTH_SSO_LABEL:-"Single Sign On"}
|
||||
AUTH_SSO_PARAMS: ${AUTH_SSO_PARAMS:-{}}
|
||||
AUTH_SSO_REDIRECT_ALLOW_LIST: ${AUTH_SSO_REDIRECT_ALLOW_LIST}
|
||||
|
||||
secrets:
|
||||
- oidc_secret
|
||||
|
||||
secrets:
|
||||
oidc_secret:
|
||||
name: ${STACK_NAME}_oidc_secret_${SECRET_OIDC_SECRET_VERSION}
|
||||
external: true
|
||||
|
||||
20
compose.smtp.yml
Normal file
20
compose.smtp.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
EMAIL_TRANSPORT: "smtp"
|
||||
EMAIL_FROM: ${EMAIL_FROM}
|
||||
EMAIL_SMTP_USER: ${EMAIL_SMTP_USER}
|
||||
EMAIL_SMTP_HOST: ${EMAIL_SMTP_HOST}
|
||||
EMAIL_SMTP_PORT: ${EMAIL_SMTP_PORT:-465}
|
||||
EMAIL_SMTP_SECURE: ${EMAIL_SMTP_SECURE:-true}
|
||||
EMAIL_SMTP_PASSWORD_FILE: /run/secrets/smtp_password
|
||||
|
||||
secrets:
|
||||
- smtp_password
|
||||
|
||||
secrets:
|
||||
smtp_password:
|
||||
name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION}
|
||||
external: true
|
||||
|
||||
17
compose.yml
17
compose.yml
@ -1,7 +1,7 @@
|
||||
---
|
||||
services:
|
||||
app:
|
||||
image: directus/directus:11.10.2
|
||||
image: directus/directus:11.16.1
|
||||
|
||||
environment:
|
||||
DB_CLIENT: pg
|
||||
@ -12,6 +12,8 @@ services:
|
||||
DB_PASSWORD_FILE: /run/secrets/db_password
|
||||
SECRET_FILE: /run/secrets/signing_secret
|
||||
|
||||
DB_POOL__MIN: 0
|
||||
|
||||
CACHE_ENABLED: "true"
|
||||
CACHE_AUTO_PURGE: "true"
|
||||
CACHE_STORE: "redis"
|
||||
@ -56,19 +58,18 @@ services:
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
## Redirect from EXTRA_DOMAINS to DOMAIN
|
||||
#- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
||||
## Redirect HTTP to HTTPS
|
||||
# - "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.scheme=https"
|
||||
# - "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.permanent=true"
|
||||
## When you're ready for release, run "abra recipe sync <name>" to set this
|
||||
- "coop-cloud.${STACK_NAME}.version=0.1.0+11.10.2"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.permanent=true"
|
||||
- "coop-cloud.${STACK_NAME}.version=0.5.0+11.15.1"
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://0.0.0.0:8055/server/health | grep -q '\"status\":\"ok\"'"]
|
||||
timeout: 10s
|
||||
timeout: 30s
|
||||
retries: 10
|
||||
start_interval: 5s
|
||||
start_period: 1m
|
||||
start_period: 90s
|
||||
|
||||
db:
|
||||
image: postgis/postgis:13-master
|
||||
|
||||
29
entrypoint.sh
Normal file
29
entrypoint.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
load_secret() {
|
||||
env_var="$1"
|
||||
secret_file="$2"
|
||||
|
||||
if [ -f "$secret_file" ]; then
|
||||
value=$(cat "$secret_file")
|
||||
if [ -z "$value" ]; then
|
||||
echo >&2 "error: $secret_file is empty"
|
||||
exit 1
|
||||
fi
|
||||
export "$env_var"="$value"
|
||||
else
|
||||
echo >&2 "[info] didn't set $env_var because $secret_file does not exist. If you don't use the secret or it is no secret at all you can safely ignore this message."
|
||||
fi
|
||||
}
|
||||
|
||||
# load every env-var that ends on _FILE
|
||||
for var in $(env | grep "_FILE="); do
|
||||
key=$(echo "$var" | sed 's/_FILE=.*//')
|
||||
value=$(echo "$var" | sed 's/.*_FILE=//')
|
||||
load_secret "$key" "$value"
|
||||
done
|
||||
|
||||
# upstream has no entrypoint https://github.com/directus/directus/blob/main/Dockerfile
|
||||
node cli.js bootstrap && pm2-runtime start ecosystem.config.cjs
|
||||
34
pg_backup.sh
Normal file
34
pg_backup.sh
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
BACKUP_FILE='/var/lib/postgresql/data/backup.sql'
|
||||
|
||||
function backup {
|
||||
export PGPASSWORD=$(cat $POSTGRES_PASSWORD_FILE)
|
||||
pg_dump -U ${POSTGRES_USER} ${POSTGRES_DB} > $BACKUP_FILE
|
||||
}
|
||||
|
||||
function restore {
|
||||
cd /var/lib/postgresql/data/
|
||||
restore_config(){
|
||||
# Restore allowed connections
|
||||
cat pg_hba.conf.bak > pg_hba.conf
|
||||
su postgres -c 'pg_ctl reload'
|
||||
}
|
||||
# Don't allow any other connections than local
|
||||
cp pg_hba.conf pg_hba.conf.bak
|
||||
echo "local all all trust" > pg_hba.conf
|
||||
su postgres -c 'pg_ctl reload'
|
||||
trap restore_config EXIT INT TERM
|
||||
|
||||
# Recreate Database
|
||||
psql -U ${POSTGRES_USER} -d postgres -c "DROP DATABASE ${POSTGRES_DB} WITH (FORCE);"
|
||||
createdb -U ${POSTGRES_USER} ${POSTGRES_DB}
|
||||
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB} -1 -f $BACKUP_FILE
|
||||
|
||||
trap - EXIT INT TERM
|
||||
restore_config
|
||||
}
|
||||
|
||||
$@
|
||||
1
release/0.3.0+11
Normal file
1
release/0.3.0+11
Normal file
@ -0,0 +1 @@
|
||||
added sso and smtp, two secrets are now optional
|
||||
1
release/0.3.1+11
Normal file
1
release/0.3.1+11
Normal file
@ -0,0 +1 @@
|
||||
added example env for sso
|
||||
1
release/0.4.0+11
Normal file
1
release/0.4.0+11
Normal file
@ -0,0 +1 @@
|
||||
compare release notes of 0.3.0 – some recipe upgrading issues
|
||||
1
release/0.4.1+11
Normal file
1
release/0.4.1+11
Normal file
@ -0,0 +1 @@
|
||||
syntax error in oidc compose when using role_mapping
|
||||
2
release/0.5.0+11.15.1
Normal file
2
release/0.5.0+11.15.1
Normal file
@ -0,0 +1,2 @@
|
||||
switched to fixed image versions as there seem to be breaking changes in minor versions.
|
||||
added docs on SSO, SMTP, directus-cli, custom env-vars for flows, so check out README.md if you need these.
|
||||
6
renovate.json
Normal file
6
renovate.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user