From a40d676162f16dffb21c07e7b8d6776ebf42f5eb Mon Sep 17 00:00:00 2001 From: Nicolas Jeudy Date: Sat, 15 Aug 2020 09:18:53 +0000 Subject: [PATCH] new: [codimd] add charm --- codimd/hooks/init | 12 ++++++ .../hooks/postgres_database-relation-joined | 17 +++++++++ codimd/metadata.yml | 38 +++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100755 codimd/hooks/init create mode 100755 codimd/hooks/postgres_database-relation-joined create mode 100644 codimd/metadata.yml diff --git a/codimd/hooks/init b/codimd/hooks/init new file mode 100755 index 0000000..56997ce --- /dev/null +++ b/codimd/hooks/init @@ -0,0 +1,12 @@ +#!/bin/bash + +init-config-add "\ +$SERVICE_NAME: + environment: + CMD_USECDN: \"false\" +" + +## ``codimd`` create uploads folder with wrong permission + +mkdir -p "$SERVICE_DATASTORE/home/hackmd/app/public/uploads" +chown -R 1500:1500 "$SERVICE_DATASTORE/home/hackmd/app/public/" diff --git a/codimd/hooks/postgres_database-relation-joined b/codimd/hooks/postgres_database-relation-joined new file mode 100755 index 0000000..4e62706 --- /dev/null +++ b/codimd/hooks/postgres_database-relation-joined @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +PASSWORD="$(relation-get password)" +USER="$(relation-get user)" +DBNAME="$(relation-get dbname)" + + +config-add "\ +services: + $MASTER_BASE_SERVICE_NAME: + environment: + CMD_DB_URL: postgres://$USER:$PASSWORD@$TARGET_SERVICE_NAME/$DBNAME +" + +info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access." diff --git a/codimd/metadata.yml b/codimd/metadata.yml new file mode 100644 index 0000000..7e4d0e6 --- /dev/null +++ b/codimd/metadata.yml @@ -0,0 +1,38 @@ +docker-image: docker.0k.io/hackmd:2.2.0 ## from: nabo.codimd.dev/hackmdio/hackmd:2.2.0 +data-resources: + - /home/hackmd/app/public/uploads + +default-options: + +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: recommended + 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/" +