Compare commits

...

3 Commits

Author SHA1 Message Date
Nicolas JEUDY 83cdac9773 fix: [docker-host] update docker version 3 years ago
Valentin Lab 73a74c63b5 fix: [etherpad] keep API key 3 years ago
Valentin Lab 11fffe0610 new: [etherpad] new charm 3 years ago
  1. 25
      etherpad/README.org
  2. 39
      etherpad/hooks/init
  3. 26
      etherpad/hooks/postgres_database-relation-joined
  4. 53
      etherpad/metadata.yml
  5. 4
      precise/host/hooks/install.d/60-docker.sh

25
etherpad/README.org

@ -0,0 +1,25 @@
# -*- ispell-local-dictionary: "english" -*-
#+TITLE: Etherpad Charm
* Upgrade
Based on https://github.com/ether/etherpad-lite , following:
https://github.com/ether/etherpad-lite/blob/develop/doc/docker.md
Used:
#+begin_src sh
TAG=1.8.14
git clone https://github.com/ether/etherpad-lite --depth 1 -b $TAG
docker build --build-arg INSTALL_SOFFICE=1 . -t docker.0k.io/etherpad:${TAG}-soffice
docker push docker.0k.io/etherpad:${TAG}-soffice
#+end_src
* Admin password
We choose to NOT include admin panel as it allows to change settings
and install plugins but this will not allow to reproduce an install
easily. We can do this on the =compose.yml= side in a reproducible
manner.

39
etherpad/hooks/init

@ -0,0 +1,39 @@
#!/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
. lib/common
set -e
dirs=(
"$SERVICE_DATASTORE/var/lib/etherpad"
)
uid_gid=($(docker_get_uid_gid "$SERVICE_NAME" "etherpad" "etherpad")) || {
err "Could not fetch uid/gid on image of service ${DARKYELLOW}$SERVICE_NAME${NORMAL}."
return 1
}
uid="${uid_gid[0]}"
gid="${uid_gid[1]}"
for dir in "${dirs[@]}"; do
mkdir -p "$dir"
find "$dir" \! -uid "$uid" -print0 | while read-0 f; do
chown -v "$uid" "$f" || return 1
done
find "$dir" \! -gid "$gid" -print0 | while read-0 f; do
chgrp -v "$gid" "$f" || return 1
done
done

26
etherpad/hooks/postgres_database-relation-joined

@ -0,0 +1,26 @@
#!/bin/bash
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
control=$(echo -en "$USER\0$DBNAME\0$PASSWORD\0$ADMIN_PASSWORD" | md5_compat)
config-add "\
services:
$MASTER_BASE_SERVICE_NAME:
environment:
DB_TYPE: postgres
DB_HOST: \"$MASTER_TARGET_SERVICE_NAME\"
DB_NAME: \"$DBNAME\"
DB_PASS: \"$PASSWORD\"
DB_USER: \"$USER\"
"
[ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
relation-set control "$control"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

53
etherpad/metadata.yml

@ -0,0 +1,53 @@
name: etherpad
summary: "Etherpad-lite server"
maintainer: "Valentin Lab <valentin.lab@kalysto.org>"
inherit: base-0k
## Custom built from git 1.8.14 https://github.com/ether/etherpad-lite with
## build arg --build-arg INSTALL_SOFFICE=1
docker-image: docker.0k.io/etherpad:1.8.14-soffice ## custom built from git m etherpad/etherpad
description: |
Etherpad-lite service.
data-resources:
- /var/lib/etherpad
docker-compose:
command: node src/node/server.js --apikey /var/lib/etherpad/APIKEY.txt
environment:
SOFFICE: '/usr/bin/soffice'
uses:
postgres-database:
#constraint: required | recommended | optional
#auto: pair | summon | none ## default: pair
constraint: required
auto: summon
solves:
database: "main storage"
default-options:
extensions:
- unaccent
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}:9001
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/"

4
precise/host/hooks/install.d/60-docker.sh

@ -14,7 +14,7 @@ fi
if [ -n "$just_installed" ]; then if [ -n "$just_installed" ]; then
need_restart= need_restart=
docker_version=17
docker_version=19.03
if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then if ! [[ "$(docker --version)" == "Docker version $docker_version"* ]]; then
version="$(apt-cache madison docker-ce | version="$(apt-cache madison docker-ce |
cut -f 2 -d \| | cut -f 2 -d \| |
@ -29,4 +29,4 @@ if [ -n "$just_installed" ]; then
systemctl daemon-reload && systemctl daemon-reload &&
service docker restart service docker restart
fi fi
fi
fi
Loading…
Cancel
Save