Compare commits
8 Commits
0.1.0+11.1
...
0.2.0+11
| Author | SHA1 | Date | |
|---|---|---|---|
| 71b43a0d00 | |||
| 0f3a6120a1 | |||
| 93e34e1077 | |||
| 818c92b3e2 | |||
| ce435071b8 | |||
| 1c5ae31ddd | |||
| a0284c5efc | |||
| 9baac5a574 |
13
.env.sample
13
.env.sample
@ -1,11 +1,14 @@
|
||||
SECRET_DB_PASSWORD_VERSION=v1
|
||||
SECRET_ADMIN_PASSWORD_VERSION=v1
|
||||
SECRET_SIGNING_SECRET_VERSION=v1
|
||||
SECRET_SMTP_PASSWORD_VERSION=v1
|
||||
|
||||
TYPE=directus
|
||||
|
||||
DOMAIN=directus.example.com
|
||||
|
||||
#IMAGE_VERSION=11.13.1
|
||||
|
||||
## Domain aliases
|
||||
#EXTRA_DOMAINS=', `www.directus.example.com`'
|
||||
|
||||
@ -13,4 +16,12 @@ LETS_ENCRYPT_ENV=production
|
||||
|
||||
ENABLE_BACKUPS=true
|
||||
|
||||
ADMIN_EMAIL=mail@example.com
|
||||
ADMIN_EMAIL=mail@example.com
|
||||
|
||||
# if you don't use smtp, sendmail is used
|
||||
# EMAIL_TRANSPORT=smtp
|
||||
#EMAIL_FROM=noreply@example.com
|
||||
# EMAIL_SMTP_USER=
|
||||
# EMAIL_SMTP_HOST=mailhost.com
|
||||
# EMAIL_SMTP_PORT=465
|
||||
# EMAIL_SMTP_SECURE=true
|
||||
@ -17,7 +17,9 @@
|
||||
|
||||
## Quick start
|
||||
|
||||
* `abra app new directus --secrets`
|
||||
* `abra app new directus`
|
||||
* `abra app secret insert <app-name> smtp_password v1 <your-smtp-password>`
|
||||
* `abra app secret generate <app-name> --all`
|
||||
* `abra app config <app-name>`
|
||||
* `abra app deploy <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=v3
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
28
compose.yml
28
compose.yml
@ -1,7 +1,7 @@
|
||||
---
|
||||
services:
|
||||
app:
|
||||
image: directus/directus:11.10.2
|
||||
image: directus/directus:${IMAGE_VERSION:-11}
|
||||
|
||||
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"
|
||||
@ -22,6 +24,13 @@ services:
|
||||
|
||||
PUBLIC_URL: https://${DOMAIN}
|
||||
|
||||
EMAIL_TRANSPORT: ${EMAIL_TRANSPORT}
|
||||
EMAIL_FROM: ${EMAIL_FROM}
|
||||
EMAIL_SMTP_USER: ${EMAIL_SMTP_USER}
|
||||
EMAIL_SMTP_HOST: ${EMAIL_SMTP_HOST}
|
||||
EMAIL_SMTP_PORT: ${EMAIL_SMTP_PORT}
|
||||
EMAIL_SMTP_SECURE: ${EMAIL_SMTP_SECURE}
|
||||
|
||||
networks:
|
||||
- proxy
|
||||
- internal
|
||||
@ -45,6 +54,7 @@ services:
|
||||
- db_password
|
||||
- admin_password
|
||||
- signing_secret
|
||||
- smtp_password
|
||||
|
||||
deploy:
|
||||
restart_policy:
|
||||
@ -56,19 +66,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.2.0+11"
|
||||
|
||||
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
|
||||
@ -134,6 +143,9 @@ secrets:
|
||||
signing_secret:
|
||||
name: ${STACK_NAME}_signing_secret_${SECRET_SIGNING_SECRET_VERSION}
|
||||
external: true
|
||||
smtp_password:
|
||||
name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION}
|
||||
external: true
|
||||
|
||||
configs:
|
||||
directus_entrypoint:
|
||||
|
||||
28
entrypoint.sh
Normal file
28
entrypoint.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/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 "error: $secret_file does not exist"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
load_secret "DB_PASSWORD" "/run/secrets/db_password"
|
||||
load_secret "ADMIN_PASSWORD" "/run/secrets/admin_password"
|
||||
load_secret "SIGNING_SECRET" "/run/secrets/signing_secret"
|
||||
load_secret "EMAIL_SMTP_PASSWORD" "/run/secrets/smtp_password"
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
$@
|
||||
Reference in New Issue
Block a user