From 1d0a78ac0818f30d8a651ba61297d6f6b71ff9ed Mon Sep 17 00:00:00 2001 From: "Franz Heinzmann (Frando)" Date: Thu, 29 Sep 2022 14:27:49 +0200 Subject: [PATCH] initial commit --- .env.sample | 7 +++++ abra.sh | 2 ++ compose.yml | 75 ++++++++++++++++++++++++++++++++++++++++++++ config.toml.tmpl | 16 ++++++++++ docker-entrypoint.sh | 4 +++ 5 files changed, 104 insertions(+) create mode 100644 .env.sample create mode 100644 abra.sh create mode 100644 compose.yml create mode 100644 config.toml.tmpl create mode 100644 docker-entrypoint.sh diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..81088eb --- /dev/null +++ b/.env.sample @@ -0,0 +1,7 @@ +TYPE=listmonk + +DOMAIN={{ .Domain }} +LETS_ENCRYPT_ENV=production + +SECRET_DB_PASSWORD_VERSION=v1 +SECRET_ADMIN_PASSWORD_VERSION=v1 diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..4a92e3c --- /dev/null +++ b/abra.sh @@ -0,0 +1,2 @@ +export CONFIG_TOML_VERSION=v1 +export APP_ENTRYPOINT_VERSION=v1 diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..e186e40 --- /dev/null +++ b/compose.yml @@ -0,0 +1,75 @@ +--- +version: "3.7" + +services: + app: + restart: unless-stopped + image: listmonk/listmonk:latest + networks: + - internal + - proxy + environment: + - TZ=Etc/UTC + - LISTMONK_DB_HOST=db + depends_on: + - db + configs: + - source: config_toml + target: /listmonk/config.toml + - source: app_entrypoint + target: /docker_entrypoint.sh + entrypoint: /docker-entrypoint.sh + deploy: + update_config: + failure_action: rollback + order: start-first + labels: + - "traefik.enable=true" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=9000" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + + db: + image: postgres:13 + networks: + - internal + secrets: + - db_password + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/db_password + - POSTGRES_USER=listmonk + - POSTGRES_DB=listmonk + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready -U listmonk"] + interval: 10s + timeout: 5s + retries: 6 + volumes: + - "postgres_data:/var/lib/postgresql/data" + +secrets: + db_password: + name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION} + external: true + admin_password: + name: ${STACK_NAME}_admin_password_${SECRET_ADMIN_PASSWORD_VERSION} + external: true + +networks: + internal: + proxy: + external: true + +volumes: + postgres_data: + +configs: + config_toml: + name: ${STACK_NAME}_config_toml_${CONFIG_TOML_VERSION} + file: config.toml.tmpl + template_driver: golang + app_entrypoint: + name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION} + file: docker-entrypoint.sh diff --git a/config.toml.tmpl b/config.toml.tmpl new file mode 100644 index 0000000..2fb5a0b --- /dev/null +++ b/config.toml.tmpl @@ -0,0 +1,16 @@ +[app] +address = "0.0.0.0:9000" +admin_username = "admin" +admin_password = "{{ secret "admin_password" }}" + +# Database. +[db] +host = "{{ env "LISTMONK_DB_HOST" }} " +port = 5432 +user = "listmonk" +password = "{{ secret "db_password" }}" +database = "listmonk" +ssl_mode = "disable" +max_open = 25 +max_idle = 25 +max_lifetime = "300s" diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..3201f71 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cd /listmonk +./listmonk --install || ./listmonk --upgrade +./listmonk