new: [plausible] add charm
This commit is contained in:
7
plausible/README.org
Normal file
7
plausible/README.org
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- ispell-local-dictionary: "english" -*-
|
||||
|
||||
* Info
|
||||
|
||||
From: https://github.com/plausible/community-edition/
|
||||
|
||||
* Usage
|
14
plausible/hooks/event_db-relation-joined
Executable file
14
plausible/hooks/event_db-relation-joined
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
|
||||
config-add "\
|
||||
services:
|
||||
$MASTER_BASE_SERVICE_NAME:
|
||||
environment:
|
||||
CLICKHOUSE_DATABASE_URL: http://$TARGET_SERVICE_NAME:8123/$TARGET_SERVICE_NAME
|
||||
"
|
||||
|
||||
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."
|
26
plausible/hooks/init
Executable file
26
plausible/hooks/init
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
SECRET_KEY_BASE="$SERVICE_DATASTORE"/secret-key
|
||||
|
||||
SHARE_DIR="$SERVICE_DATASTORE"/var/lib/plausible
|
||||
|
||||
uid=$(docker_get_uid "$SERVICE_NAME" "plausible")
|
||||
|
||||
if ! [ -f "$SECRET_KEY_BASE" ]; then
|
||||
info "Generating secret key"
|
||||
mkdir -p "${SECRET_KEY_BASE%/*}"
|
||||
umask 077
|
||||
openssl rand -base64 64 > "$SECRET_KEY_BASE"
|
||||
else
|
||||
info "Using existing secret key"
|
||||
fi
|
||||
|
||||
secret_key_base=$(cat "$SECRET_KEY_BASE")
|
||||
|
||||
init-config-add "
|
||||
$SERVICE_NAME:
|
||||
environment:
|
||||
SECRET_KEY_BASE: \"$secret_key_base\"
|
||||
"
|
||||
|
||||
chown -v "$uid" "$SHARE_DIR"
|
17
plausible/hooks/postgres_database-relation-joined
Executable file
17
plausible/hooks/postgres_database-relation-joined
Executable file
@@ -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:
|
||||
DATABASE_URL: postgres://$USER:$PASSWORD@$TARGET_SERVICE_NAME:5432/$DBNAME
|
||||
"
|
||||
|
||||
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."
|
21
plausible/hooks/smtp_server-relation-joined
Executable file
21
plausible/hooks/smtp_server-relation-joined
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
host=$(relation-get host) || exit 1
|
||||
port=$(relation-get port) || exit 1
|
||||
user=$(relation-get login) || exit 1
|
||||
password="$(relation-get password)" || exit 1
|
||||
|
||||
|
||||
config-add "\
|
||||
services:
|
||||
$MASTER_BASE_SERVICE_NAME:
|
||||
environment:
|
||||
SMTP_HOST_NAME: \"$user\"
|
||||
SMTP_HOST_PASS: \"${password//\$/\$\$}\"
|
||||
SMTP_HOST_ADDR: \"$host\"
|
||||
SMTP_HOST_PORT: \"$port\"
|
||||
# SMTP_HOST_SSL_ENABLE: \"true\"
|
||||
"
|
||||
|
16
plausible/hooks/web_proxy-relation-joined
Executable file
16
plausible/hooks/web_proxy-relation-joined
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
DOMAIN=$(relation-get domain) || {
|
||||
echo "Failed to get domain"
|
||||
exit 1
|
||||
}
|
||||
|
||||
config-add "\
|
||||
services:
|
||||
$MASTER_BASE_SERVICE_NAME:
|
||||
environment:
|
||||
BASE_URL: \"https:\/\/${DOMAIN}\"
|
||||
"
|
||||
|
58
plausible/metadata.yml
Normal file
58
plausible/metadata.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
docker-image: docker.0k.io/plausible:3.0.1
|
||||
#docker-image: ghcr.io/plausible/community-edition:v3.0.1
|
||||
|
||||
data-resources:
|
||||
- /var/lib/plausible
|
||||
|
||||
docker-compose:
|
||||
entrypoint: sh -c "/entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
|
||||
#entrypoint: sh -c "/entrypoint.sh run"
|
||||
uses:
|
||||
event-db:
|
||||
#constraint: required | recommended | optional
|
||||
#auto: pair | summon | none ## default: pair
|
||||
constraint: required
|
||||
auto: summon
|
||||
solves:
|
||||
database: "event db"
|
||||
postgres-database:
|
||||
#constraint: required | recommended | optional
|
||||
#auto: pair | summon | none ## default: pair
|
||||
constraint: required
|
||||
auto: summon
|
||||
solves:
|
||||
database: "main storage"
|
||||
default-options:
|
||||
extensions:
|
||||
- citext
|
||||
smtp-server:
|
||||
constraint: required
|
||||
auto: summon
|
||||
solves:
|
||||
proxy: "Public access"
|
||||
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}:8000
|
||||
apache-custom-rules:
|
||||
- !var-expand |
|
||||
ProxyPreserveHost On
|
||||
|
||||
#Set web sockets
|
||||
RewriteEngine On
|
||||
RewriteCond %{HTTP:Upgrade} =websocket [NC]
|
||||
RewriteCond %{HTTP:Connection} upgrade [NC]
|
||||
RewriteRule ^/(live/websocket)$ ws://${MASTER_BASE_SERVICE_NAME}:8000/\$1 [P,L]
|
||||
|
||||
|
||||
backup:
|
||||
constraint: recommended
|
||||
auto: pair
|
||||
solves:
|
||||
backup: "Automatic regular backup"
|
||||
default-options:
|
Reference in New Issue
Block a user