commit afe80ca3af92b42b0368dfa87891a4d7e21a13eb Author: Aadil Ayub Date: Fri Jul 9 18:20:28 2021 +0500 package abra diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..dba2e86 --- /dev/null +++ b/.env.sample @@ -0,0 +1,7 @@ +TYPE=monica + +DOMAIN=monica.example.com +## Domain aliases +#EXTRA_DOMAINS=', `www.monica.example.com`' +LETS_ENCRYPT_ENV=production +SECRET_APP_KEY_VERSION=v1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..37b52cc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.envrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..119c24f --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# monica + +Monica is a great open source personal relationship management system. + + +* **Category**: +* **Status**: +* **Image**: [`monica`](https://hub.docker.com/r/monica/monica) +* **Healthcheck**: +* **Backups**: +* **Email**: +* **Tests**: +* **SSO**: + + +## Basic usage + +1. Set up Docker Swarm and [`abra`] +2. Deploy [`coop-cloud/traefik`] +3. `abra app new monica --secrets` (optionally with `--pass` if you'd like + to save secrets in `pass`) +4. `abra app YOURAPPDOMAIN config` - be sure to change `$DOMAIN` to something that resolves to + your Docker swarm box +5. `abra app YOURAPPDOMAIN deploy` +6. Open the configured domain in your browser to finish set-up + +[`abra`]: https://git.autonomic.zone/autonomic-cooperative/abra +[`coop-cloud/traefik`]: https://git.autonomic.zone/coop-cloud/traefik diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..5c54e9d --- /dev/null +++ b/abra.sh @@ -0,0 +1 @@ +export ENTRYPOINT_CONF_VERSION=v1 diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..b649124 --- /dev/null +++ b/compose.yml @@ -0,0 +1,81 @@ + +--- +version: "3.8" + +services: + app: + image: monica + networks: + - proxy + - internal + volumes: + - data:/var/www/html/storage + environment: + - APP_KEY_FILE=/run/secrets/app_key + - APP_URL=https://$DOMAIN + - APP_TRUSTED_PROXIES=* + - DB_HOST=db + - DB_USERNAME=monica + - DB_PASSWORD=secret + secrets: + - app_key + configs: + - source: entrypoint_conf + target: /docker-entrypoint.sh + mode: 0555 + deploy: + restart_policy: + condition: on-failure + labels: + - "traefik.enable=true" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + ## Redirect from EXTRA_DOMAINS to DOMAIN + #- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect" + #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true" + #- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" + # healthcheck: + # test: ["CMD", "curl", "-f", "http://localhost:8080"] + # interval: 30s + # timeout: 10s + # retries: 10 + # start_period: 1m + + + db: + image: mysql:5.7 + environment: + - MYSQL_RANDOM_ROOT_PASSWORD=true + - MYSQL_DATABASE=monica + - MYSQL_USER=monica + - MYSQL_PASSWORD=secret + volumes: + - mysql:/var/lib/mysql + networks: + - internal + deploy: + restart_policy: + condition: on-failure + +secrets: + app_key: + external: true + name: ${STACK_NAME}_app_key_${SECRET_APP_KEY_VERSION} + +configs: + entrypoint_conf: + name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION} + file: entrypoint.sh.tmpl + template_driver: golang + +volumes: + data: + mysql: + +networks: + proxy: + external: true + internal: + internal: true diff --git a/entrypoint.sh.tmpl b/entrypoint.sh.tmpl new file mode 100644 index 0000000..9bed8f0 --- /dev/null +++ b/entrypoint.sh.tmpl @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +file_env() { + # 3wc: Load $VAR_FILE into $VAR - useful for secrets. See + # https://medium.com/@adrian.gheorghe.dev/using-docker-secrets-in-your-environment-variables-7a0609659aab + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +load_vars() { + file_env "APP_KEY" +} + +main() { + set -eu + + load_vars +} + +main + +# 3wc: upstream ENTRYPOINT +/usr/local/bin/entrypoint.sh