commit cc48f7761ced1980a54f17ef946eed06f77e71bc Author: C Ræv Date: Tue Sep 28 00:55:27 2021 +0200 Initial import diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fc3544a --- /dev/null +++ b/.drone.yml @@ -0,0 +1,56 @@ +--- +kind: pipeline +name: deploy to swarm-test.autonomic.zone +steps: + - name: deployment + image: decentral1se/stack-ssh-deploy:latest + settings: + host: swarm-test.autonomic.zone + stack: plausible + purge: true + deploy_key: + from_secret: drone_ssh_swarm_test + environment: + DOMAIN: plausible.swarm-test.autonomic.zone + LETS_ENCRYPT_ENV: production + + - name: notify coopcloud-dev on failure + image: plugins/matrix + settings: + homeserver: https://matrix.autonomic.zone + roomid: "IFazIpLtxiScqbHqoa:autonomic.zone" + userid: "@autono-bot:autonomic.zone" + accesstoken: + from_secret: autono_bot_access_token + depends_on: + - deployment + when: + status: + - failure +trigger: + branch: + - main + +--- +kind: pipeline +name: recipe release +steps: + - name: release a new version + image: decentral1se/drone-abra:latest + settings: + command: recipe plausible release + deploy_key: + from_secret: abra_bot_deploy_key + + - name: trigger downstream builds + image: plugins/downstream + settings: + server: https://drone.autonomic.zone + token: + from_secret: decentral1se_token + fork: true + repositories: + - coop-cloud/auto-apps-json + depends_on: + - release a new version +rsion diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..a3c46fc --- /dev/null +++ b/.env.sample @@ -0,0 +1,12 @@ +TYPE=plausible + +DOMAIN=plausible.example.com + +## Domain aliases +#EXTRA_DOMAINS=', `www.plausible.example.com`' +LETS_ENCRYPT_ENV=production + +ADMIN_USER_EMAIL=replace-me +ADMIN_USER_NAME=replace-me +ADMIN_USER_PWD=replace-me +SECRET_KEY_BASE=replace-me diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a6353d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.envrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..7847e63 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# plausible + +TODO + + + +- **Category**: +- **Status**: +- **Image**: +- **Healthcheck**: +- **Backups**: +- **Email**: +- **Tests**: +- **SSO**: + + + +## Basic usage + +1. Set up Docker Swarm and [`abra`] +2. Deploy [`coop-cloud/traefik`] +3. `abra app new ${REPO_NAME} --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.coopcloud.tech/coop-cloud/abra +[`coop-cloud/traefik`]: https://git.coopcloud.tech/coop-cloud/traefik +p-cloud/traefik diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..e96cc77 --- /dev/null +++ b/abra.sh @@ -0,0 +1,2 @@ +export CLICKHOUSE_CONF_VERSION=v1 +export CLICKHOUSE_USER_CONF_VERSION=v2 diff --git a/clickhouse-config.xml b/clickhouse-config.xml new file mode 100644 index 0000000..b2098d5 --- /dev/null +++ b/clickhouse-config.xml @@ -0,0 +1,15 @@ + + + warning + true + + + + + + + + + + + diff --git a/clickhouse-user-config.xml b/clickhouse-user-config.xml new file mode 100644 index 0000000..f795286 --- /dev/null +++ b/clickhouse-user-config.xml @@ -0,0 +1,8 @@ + + + + 0 + 0 + + + diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..1dd35bb --- /dev/null +++ b/compose.yml @@ -0,0 +1,81 @@ +--- +version: "3.8" + +services: + app: + image: plausible/analytics:latest + command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run" + depends_on: + - db + - events_db + environment: + - BASE_URL=https://$DOMAIN + - ADMIN_USER_EMAIL + - ADMIN_USER_NAME + - ADMIN_USER_PWD + - SECRET_KEY_BASE + - DATABASE_URL=postgres://plausible:plausible@${STACK_NAME}_db:5432/plausible + - SMTP_HOST_ADDR + - MAILER_EMAIL + networks: + - proxy + - internal + deploy: + restart_policy: + condition: on-failure + labels: + - "traefik.enable=true" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8000" + - "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"] + # interval: 30s + # timeout: 10s + # retries: 10 + # start_period: 1m + + db: + image: postgres:12 + volumes: + - db-data:/var/lib/postgresql/data + environment: + - POSTGRES_USER=plausible + - POSTGRES_PASSWORD=plausible + - POSTGRES_DB=plausible + networks: + - internal + + plausible_events_db: + image: yandex/clickhouse-server:21.3.2.5 + volumes: + - event-data:/var/lib/clickhouse + configs: + - source: clickhouse-config + target: /etc/clickhouse-server/config.d/logging.xml + - source: clickhouse-user-config + target: /etc/clickhouse-server/users.d/clickhouse-user-config.xml + networks: + - internal + +volumes: + db-data: + event-data: + +networks: + proxy: + external: true + internal: + +configs: + clickhouse-config: + name: ${STACK_NAME}_clickhouse_config_${CLICKHOUSE_CONF_VERSION} + file: clickhouse-config.xml + clickhouse-user-config: + name: ${STACK_NAME}_clickhouse_user_config_${CLICKHOUSE_USER_CONF_VERSION} + file: clickhouse-user-config.xml