Boris Gallet
11 months ago
committed by
Valentin Lab
7 changed files with 191 additions and 0 deletions
-
29rallly/README.org
-
38rallly/hooks/init
-
18rallly/hooks/postgres_database-relation-joined
-
54rallly/hooks/smtp_server-relation-joined
-
12rallly/hooks/web_proxy-relation-joined
-
32rallly/metadata.yml
-
8rallly/resources/app/docker-start.sh
@ -0,0 +1,29 @@ |
|||
# -*- ispell-local-dictionary: "english" -*- |
|||
|
|||
* Info |
|||
|
|||
From: https://github.com/lukevella/rallly |
|||
|
|||
* Usage |
|||
|
|||
Config info: https://support.rallly.co/self-hosting/configuration-options |
|||
|
|||
Requires a =smtp-server= provider to be functional, you can use |
|||
=smtp-stub= charm to provide information to externally managed =SMTP=. |
|||
|
|||
#+begin_src yaml |
|||
rallly: |
|||
options: |
|||
support-email: support@myhost.com # is used as the sender of auth emails |
|||
#allowed-emails: "*@example.coop, test@example2.com" |
|||
|
|||
smtp-stub: |
|||
options: |
|||
host: smtp.myhost.com |
|||
port: 465 |
|||
connection-security: "ssl/tls" |
|||
auth-method: password |
|||
user: myuser |
|||
password: myp4ssw0rd |
|||
#+end_src |
|||
|
@ -0,0 +1,38 @@ |
|||
#!/bin/bash |
|||
|
|||
set -e |
|||
|
|||
## bug: https://github.com/adoptium/containers/issues/215#issuecomment-1142046045 |
|||
docker_version=$(docker info --format '{{.ServerVersion}}') |
|||
if ! version_gt "$docker_version" 20.10.0; then |
|||
err "Sorry, $SERVICE_NAME require docker version >= 20.10 (current: $docker_version)" |
|||
exit 1 |
|||
fi |
|||
|
|||
|
|||
PASSWORD_FILE="$SERVICE_DATASTORE"/secret-password |
|||
|
|||
if ! [ -f "$PASSWORD_FILE" ]; then |
|||
info "Generating secret password" |
|||
mkdir -p "${PASSWORD_FILE%/*}" |
|||
umask 077 |
|||
openssl rand -base64 32 > "$PASSWORD_FILE" |
|||
else |
|||
info "Using existing secret password" |
|||
fi |
|||
|
|||
secret_password=$(cat "$PASSWORD_FILE") |
|||
support_email=$(options-get support-email) |
|||
allowed_emails=$(options-get allowed-emails "") || true |
|||
|
|||
if [ -z "$allowed_emails" ]; then |
|||
allowed_emails="*" |
|||
fi |
|||
|
|||
init-config-add "\ |
|||
$MASTER_BASE_SERVICE_NAME: |
|||
environment: |
|||
SECRET_PASSWORD: \"$secret_password\" |
|||
SUPPORT_EMAIL: \"$support_email\" |
|||
ALLOWED_EMAILS: \"$allowed_emails\" |
|||
" |
@ -0,0 +1,18 @@ |
|||
#!/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/$DBNAME\" |
|||
" |
|||
|
|||
|
|||
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access." |
@ -0,0 +1,54 @@ |
|||
#!/bin/bash |
|||
|
|||
set -e |
|||
|
|||
host=$(relation-get host) |
|||
port=$(relation-get port) |
|||
connection_security=$(relation-get connection-security) |
|||
auth_method=$(relation-get auth-method) |
|||
|
|||
declare -A ENV |
|||
case "$connection_security" in |
|||
"none") |
|||
secure="false" |
|||
;; |
|||
"starttls") |
|||
secure="true" |
|||
ENV[SMTP_TLS_ENABLED]="true" |
|||
;; |
|||
"ssl/tls") |
|||
secure="true" |
|||
ENV[SMTP_SECURE]="true" |
|||
ENV[SMTP_TLS_ENABLED]="true" |
|||
;; |
|||
*) |
|||
error "Unsupported connection security: $connection_security" |
|||
exit 1 |
|||
;; |
|||
esac |
|||
case "$auth_method" in |
|||
"none") |
|||
: |
|||
;; |
|||
"password") |
|||
login=$(relation-get login) || true |
|||
password=$(relation-get password) || true |
|||
ENV[SMTP_USER]="$login" |
|||
ENV[SMTP_PWD]="$password" |
|||
;; |
|||
*) |
|||
error "Unsupported auth method: $auth_method" |
|||
exit 1 |
|||
;; |
|||
esac |
|||
|
|||
|
|||
config-add "\ |
|||
services: |
|||
$MASTER_BASE_SERVICE_NAME: |
|||
environment: |
|||
SMTP_HOST: \"$host\" |
|||
SMTP_PORT: \"$port\" |
|||
$(for key in "${!ENV[@]}"; do echo " $key: \"${ENV[$key]//\$/\$\$}\""; done) |
|||
" |
|||
|
@ -0,0 +1,12 @@ |
|||
#!/bin/bash |
|||
|
|||
set -e |
|||
|
|||
url=$(relation-get url) |
|||
|
|||
config-add "\ |
|||
services: |
|||
$MASTER_BASE_SERVICE_NAME: |
|||
environment: |
|||
NEXT_PUBLIC_BASE_URL: \"$url\" |
|||
" |
@ -0,0 +1,32 @@ |
|||
|
|||
docker-image: docker.0k.io/rallly:3.3.0 |
|||
|
|||
charm-resources: |
|||
- /app/docker-start.sh |
|||
|
|||
default-options: |
|||
|
|||
uses: |
|||
postgres-database: |
|||
#constraint: required | recommended | optional |
|||
#auto: pair | summon | none ## default: pair |
|||
constraint: required |
|||
auto: summon |
|||
solves: |
|||
database: "main storage" |
|||
default-options: |
|||
extensions: |
|||
- pgcrypto |
|||
- citext |
|||
web-proxy: |
|||
constraint: recommended |
|||
auto: pair |
|||
solves: |
|||
proxy: "Public access" |
|||
default-options: |
|||
target: !var-expand ${MASTER_BASE_SERVICE_NAME}:3000 |
|||
smtp-server: |
|||
constraint: required |
|||
auto: pair |
|||
solves: |
|||
proxy: "Public access" |
@ -0,0 +1,8 @@ |
|||
#!/bin/bash |
|||
set -e |
|||
prisma migrate deploy --schema=./prisma/schema.prisma |
|||
if [ -z "$NEXT_PUBLIC_BASE_URL" ]; then |
|||
IPS=($(hostname -I)) |
|||
NEXT_PUBLIC_BASE_URL="http://${IPS[0]}:3000" |
|||
fi |
|||
NEXTAUTH_URL=$NEXT_PUBLIC_BASE_URL node apps/web/server.js |
Write
Preview
Loading…
Cancel
Save
Reference in new issue