From 130067d4358f59b306a23e58dd57ec305444e85f Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Wed, 19 Feb 2025 17:09:42 -0800 Subject: [PATCH] listmonk ready for production --- listmonk/.env | 4 ++ listmonk/config/config.toml | 24 ++++++++ listmonk/docker-compose.yml | 120 +++++++++++++++--------------------- listmonk/sample.env | 4 ++ 4 files changed, 80 insertions(+), 72 deletions(-) create mode 100644 listmonk/.env create mode 100644 listmonk/config/config.toml create mode 100644 listmonk/sample.env diff --git a/listmonk/.env b/listmonk/.env new file mode 100644 index 0000000..81057c5 --- /dev/null +++ b/listmonk/.env @@ -0,0 +1,4 @@ +POSTGRES_USER=listmonk +POSTGRES_PASSWORD=securepassword +POSTGRES_DB=listmonk +SECRET_KEY=your_super_secret_key \ No newline at end of file diff --git a/listmonk/config/config.toml b/listmonk/config/config.toml new file mode 100644 index 0000000..d38a16c --- /dev/null +++ b/listmonk/config/config.toml @@ -0,0 +1,24 @@ +[app] +# Interface and port where the app will run its webserver. The default value +# of localhost will only listen to connections from the current machine. To +# listen on all interfaces use '0.0.0.0'. To listen on the default web address +# port, use port 80 (this will require running with elevated permissions). +address = "0.0.0.0:9000" + +# Database. +[db] +host = "listmonk-db" +port = 5432 +user = "listmonk" +password = "securepassword" + +# Ensure that this database has been created in Postgres. +database = "listmonk" + +ssl_mode = "disable" +max_open = 25 +max_idle = 25 +max_lifetime = "300s" + +# Optional space separated Postgres DSN params. eg: "application_name=listmonk gssencmode=disable" +params = "" \ No newline at end of file diff --git a/listmonk/docker-compose.yml b/listmonk/docker-compose.yml index 3b10152..a7a9c2a 100644 --- a/listmonk/docker-compose.yml +++ b/listmonk/docker-compose.yml @@ -1,84 +1,60 @@ -# NOT TESTED -# NOTE: This docker-compose.yml is meant to be just an example guideline -# on how you can achieve the same. It is not intented to run out of the box -# and you must edit the below configurations to suit your needs. -# https://github.com/knadh/listmonk/blob/master/docker-compose.yml - -x-app-defaults: &app-defaults - restart: unless-stopped - image: listmonk/listmonk:latest - ports: - - "9000:9000" - networks: - - listmonk - environment: - - TZ=Etc/UTC - -x-db-defaults: &db-defaults - image: postgres:13-alpine - ports: - - "9432:5432" - networks: - - listmonk - environment: - - POSTGRES_PASSWORD=listmonk - - POSTGRES_USER=listmonk - - POSTGRES_DB=listmonk - restart: unless-stopped - healthcheck: - test: ["CMD-SHELL", "pg_isready -U listmonk"] - interval: 10s - timeout: 5s - retries: 6 - services: - db: - <<: *db-defaults - container_name: listmonk_db + listmonk-db: + image: postgres:13-alpine + restart: unless-stopped + networks: + - listmonk + environment: + - POSTGRES_USER=${POSTGRES_USER:-listmonk} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-securepassword} + - POSTGRES_DB=${POSTGRES_DB:-listmonk} volumes: - - type: volume - source: listmonk-data - target: /var/lib/postgresql/data + - listmonk-data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER"] + interval: 10s + timeout: 5s + retries: 6 - app: - <<: *app-defaults - container_name: listmonk_app + listmonk-init: + image: listmonk/listmonk:latest depends_on: - - db + listmonk-db: + condition: service_healthy + networks: + - listmonk volumes: - - ./config.toml:/listmonk/config.toml + - ./config/config.toml:/listmonk/config.toml + command: [ "sh", "-c", "yes | ./listmonk --install --config /listmonk/config.toml" ] - demo-db: - container_name: listmonk_demo_db - <<: *db-defaults - - demo-app: - <<: *app-defaults - container_name: listmonk_demo_app - command: [sh, -c, "yes | ./listmonk --install --config config-demo.toml && ./listmonk --config config-demo.toml"] + listmonk: + image: listmonk/listmonk:latest + restart: unless-stopped depends_on: - - demo-db + listmonk-db: + condition: service_healthy + listmonk-init: + condition: service_completed_successfully + ports: + - "9000:9000" + networks: + - listmonk + volumes: + - ./config/config.toml:/listmonk/config.toml + - ./data/listmonk:/app/data + environment: + - SECRET_KEY=${SECRET_KEY} + - DB_PROVIDER=postgres + - DB_HOST=db + - DB_PORT=5432 + - DB_USER=${POSTGRES_USER:-listmonk} + - DB_PASSWORD=${POSTGRES_DB:-listmonk} + - DB_NAME=${POSTGRES_DB} + - WEB_SERVER_HOST=0.0.0.0 + - WEB_SERVER_PORT=8000 networks: listmonk: volumes: - listmonk-data: - -version: '3' - -services: - listmonk: - image: listmonk/listmonk:latest - container_name: listmonk - restart: always - ports: - - "9000:9000" - volumes: - - ./data/listmonk:/app/data - environment: - - SECRET_KEY= - - DB_PROVIDER=sqlite3 - - DB_SOURCE=/app/data/listmonk.db - - WEB_SERVER_HOST=localhost - - WEB_SERVER_PORT=9000 + listmonk-data: \ No newline at end of file diff --git a/listmonk/sample.env b/listmonk/sample.env new file mode 100644 index 0000000..81057c5 --- /dev/null +++ b/listmonk/sample.env @@ -0,0 +1,4 @@ +POSTGRES_USER=listmonk +POSTGRES_PASSWORD=securepassword +POSTGRES_DB=listmonk +SECRET_KEY=your_super_secret_key \ No newline at end of file