Browse Source

new: [docuseal] init charm

Boris Gallet 1 year ago
parent
commit
da8a9c1793
  1. 5
      docuseal/README.org
  2. 24
      docuseal/hooks/init
  3. 15
      docuseal/hooks/postgres_database-relation-joined
  4. 21
      docuseal/hooks/web_proxy-relation-joined
  5. 35
      docuseal/metadata.yml

5
docuseal/README.org

@ -0,0 +1,5 @@
# -*- ispell-local-dictionary: "english" -*-
## Charm for DocuSeal - allow to sign Documents
repo : https://github.com/docusealco/docuseal

24
docuseal/hooks/init

@ -0,0 +1,24 @@
#!/bin/bash
## Init is run on host
## For now it is run every time the script is launched, but
## it should be launched only once after build.
## Accessible variables are:
## - SERVICE_NAME Name of current service
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
set -e
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
## bug: https://github.com/adoptium/containers/issues/215#issuecomment-1142046045
docker_version=$(docker info --format '{{.ServerVersion}}')
if ! version_gt "$docker_version" 20.10.0; then
err "Sorry, $SERVICE_NAME require docker version >= 20.10 (current: $docker_version)"
exit 1
fi

15
docuseal/hooks/postgres_database-relation-joined

@ -0,0 +1,15 @@
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DATABASE_URL: postgres://$USER:$PASSWORD@$TARGET_SERVICE_NAME/$DBNAME
"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

21
docuseal/hooks/web_proxy-relation-joined

@ -0,0 +1,21 @@
#!/bin/bash
set -e
DOMAIN=$(relation-get domain) || exit 1
## These are mainly to setup the correct web-hook
if [ "$MASTER_BASE_SERVICE_NAME" == "$DOMAIN" ]; then
## This is because the IP will be the docker container version
USESSL=""
else
USESSL="CMD_PROTOCOL_USESSL: 'true'"
fi
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
FORCE_SSL: $DOMAIN
$USESSL
"

35
docuseal/metadata.yml

@ -0,0 +1,35 @@
docker-image: docuseal/docuseal:latest
data-resources:
- /data
uses:
postgres-database:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: required
auto: summon
solves:
database: "main storage"
web-proxy:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: recommended
auto: pair
solves:
proxy: "Public access"
default-options:
target: !var-expand ${MASTER_BASE_SERVICE_NAME}:3000
backup:
constraint: optional
auto: pair
solves:
backup: "Automatic regular backup"
default-options:
## First pattern matching wins, no pattern matching includes.
## include-patterns are checked first, then exclude-patterns
## Patterns rules:
## - ending / for directory
## - '*' authorized
## - must start with a '/', will start from $SERVICE_DATASTORE
#exclude-patterns:
# - "/var/lib/odoo/sessions/"
Loading…
Cancel
Save