Browse Source

new: [discourse] add charm

discourse
Boris Gallet 1 year ago
parent
commit
81768fd0f8
  1. 31
      discourse/README.org
  2. 22
      discourse/hooks/init
  3. 20
      discourse/hooks/postgres_database-relation-joined
  4. 15
      discourse/hooks/redis_database-relation-joined
  5. 13
      discourse/hooks/web_proxy-relation-joined
  6. 52
      discourse/metadata.yml

31
discourse/README.org

@ -0,0 +1,31 @@
# -*- ispell-local-dictionary: "english" -*-
* Info
From: https://hub.docker.com/r/bitnami/discourse
* Usage
Need a complete SMTP config to be functionnal
#+begin_src yaml
rallly:
charm: rallly
docker-compose:
options:
secret: <>
support_email: # email used for support
# OPTIONAL
allowed_emails: "*@example.coop, test@example2.com" # All by default if not set
smtp-extern:
charm: smtp-extern
options:
host: <smtp.host>
port: <465>
secure: "true"
user: <smtp user>
password: <smtp password>
#+end_src

22
discourse/hooks/init

@ -0,0 +1,22 @@
#!/bin/bash
set -e
username="$(options-get username)" || exit 1
password="$(options-get password)" || exit 1
email="$(options-get email)" || exit 1
first_name="$(options-get first_name)" || exit 1
last_name="$(options-get last_name)" || exit 1
site_name="$(options-get site_name)" || exit 1
init-config-add "\
$SERVICE_NAME:
environment:
DISCOURSE_USERNAME: $username
DISCOURSE_PASSWORD: $password
DISCOURSE_EMAIL: $email
DISCOURSE_FIRST_NAME: $first_name
DISCOURSE_LAST_NAME: $last_name
DISCOURSE_SITE_NAME: $site_name
"

20
discourse/hooks/postgres_database-relation-joined

@ -0,0 +1,20 @@
#!/bin/bash
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DISCOURSE_DATABASE_USER: $USER
DISCOURSE_DATABASE_PASSWORD: $PASSWORD
DISCOURSE_DATABASE_HOST: $TARGET_SERVICE_NAME
DISCOURSE_DATABASE_NAME: $DBNAME
"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

15
discourse/hooks/redis_database-relation-joined

@ -0,0 +1,15 @@
#!/bin/bash
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
# Configure Discourse to use a separate Redis server
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DISCOURSE_REDIS_USER: $USER
DISCOURSE_REDIS_PASSWORD: $PASSWORD
DISCOURSE_REDIS_HOST: $TARGET_SERVICE_NAME
"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

13
discourse/hooks/web_proxy-relation-joined

@ -0,0 +1,13 @@
#!/bin/bash
set -e
DOMAIN=$(relation-get domain) || exit 1
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DISCOURSE_HOST: $DOMAIN
"

52
discourse/metadata.yml

@ -0,0 +1,52 @@
docker-image: bitnami/discourse:latest
data-resources:
- /bitnami/discourse
data-config:
- /templates/
uses:
postgres-database:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: required
auto: summon
solves:
database: "main storage"
options:
extensions:
- hstore
- pg_trgm
redis-database:
constraint: required
auto: summon
solves:
redis: "short time storage"
smtp-server:
constraint: required
auto: pair
solves:
smtp: "mail sending"
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/"
Loading…
Cancel
Save