Browse Source

new: [rocketchat] new charm

framadate
Valentin Lab 5 years ago
parent
commit
dff9e49799
  1. 26
      rocketchat/hooks/init
  2. 20
      rocketchat/hooks/mongo_database-relation-joined
  3. 12
      rocketchat/hooks/web_proxy-relation-joined
  4. 33
      rocketchat/metadata.yml

26
rocketchat/hooks/init

@ -0,0 +1,26 @@
#!/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
uid=$(docker_get_uid "$SERVICE_NAME" "rocketchat")
dirs=(/app/uploads )
host_dirs=()
for dir in "${dirs[@]}"; do
host_dirs+=("$SERVICE_DATASTORE$dir")
done
mkdir -p "${host_dirs[@]}"
find "${host_dirs[@]}" \! -user "$uid" \
-exec chown -v "$uid" {} + || true

20
rocketchat/hooks/mongo_database-relation-joined

@ -0,0 +1,20 @@
#!/bin/bash
set -e
DBNAME="$(relation-get dbname)" || exit 1
MONGO_URL=mongodb://${TARGET_SERVICE_NAME}:27017/${PROJECT_NAME}_${DBNAME}?replicaSet=rs01
MONGO_OPLOG_URL=mongodb://${TARGET_SERVICE_NAME}:27017/local?replicaSet=rs01
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
MONGO_URL: $MONGO_URL
MONGO_OPLOG_URL: $MONGO_OPLOG_URL
"

12
rocketchat/hooks/web_proxy-relation-joined

@ -0,0 +1,12 @@
#!/bin/bash
set -e
URL="$(relation-get url)" || exit 1
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
ROOT_URL: $URL
"

33
rocketchat/metadata.yml

@ -0,0 +1,33 @@
summary: "Rocket Chat server"
maintainer: "Valentin Lab <valentin.lab@kalysto.org>"
docker-image: docker.0k.io/rocketchat:2.1.0
data-resources:
- /app/uploads
uses:
mongo-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
apache-custom-rules:
- !var-expand |
ProxyPreserveHost On
# Set web sockets
RewriteEngine On
RewriteCond %{REQUEST_URI} /(.*)/websocket [NC,OR]
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://${MASTER_BASE_SERVICE_NAME}:3000%{REQUEST_URI} [P,QSA,L]
Loading…
Cancel
Save