From ac9e887b925346866bdd910e7a8a0429d0035c8e Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 7 Nov 2020 14:22:17 +0100 Subject: [PATCH] First stab at wiring things up --- compose.yml | 87 ++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh.tmpl | 1 + 2 files changed, 88 insertions(+) create mode 100644 compose.yml create mode 100644 entrypoint.sh.tmpl diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..7af3fcc --- /dev/null +++ b/compose.yml @@ -0,0 +1,87 @@ +--- +version: "3.8" + +# TODO(decentral1se): +# - healthchecks +# - how do i expose multiple ports, core and web both need to have open ports +# - core receives relayed emails, web receives typical http traffic +# - ahhh! do $name-http, $name-ltmp, "name-$proto" for entrypoints on same service +# - inspect if we need a nginx proxy for mailman-web, it is currently using uwsgi +# but apparently it can serve http but in a very limited way, need to investigate +# this +# - re-wire up all that static IP stuff so things know where each other are in +# the stack, e.g. https://github.com/maxking/docker-mailman/blob/master/docker-compose.yaml#L55 + +services: + # TODO(decentral1se): https://github.com/maxking/docker-mailman#mailman-core-1 + core: + image: "maxking/mailman-core:0.3" + volumes: + - "core:/opt/mailman/" + configs: + - source: entrypoint_conf + target: /docker-entrypoint.sh + mode: 0555 + # TODO(decentral1se): https://github.com/maxking/docker-mailman/blob/master/core/Dockerfile + # build up the right env vars required in the entrypoint via the secrets loading + entrypoint: /docker-entrypoint.sh + environment: + - DATABASE_CLASS=mailman.database.postgresql.PostgreSQLDatabase + - DATABASE_DB=mailman + - DATABASE_NAME=mailman + - DATABASE_TYPE=postgres + - DATABASE_USER=mailman + # TODO(decentral1se): https://github.com/maxking/docker-mailman/blob/master/core/Dockerfile + + # TODO(decentral1se): https://github.com/maxking/docker-mailman#mailman-web-1 + web: + image: "maxking/mailman-web:0.3" + volumes: + - "web:/opt/mailman-web-data" + configs: + - source: entrypoint_conf + target: /docker-entrypoint.sh + mode: 0555 + # TODO(decentral1se): https://github.com/maxking/docker-mailman/blob/master/core/Dockerfile + # build up the right env vars required in the entrypoint via the secrets loading + entrypoint: /docker-entrypoint.sh + environment: + - DATABASE_TYPE=postgres + deploy: + update_config: + failure_action: rollback + order: start-first + labels: + - "traefik.enable=true" + # TODO(decentral1se): https://github.com/maxking/docker-mailman/blob/master/web/Dockerfile + - "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=${8000}" + - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" + - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}" + + db: + image: "postgres:13-alpine" + secrets: + - db_password + environment: + POSTGRES_DB: mailman + POSTGRES_USER: mailman + POSTGRES_PASSWORD_FILE: /run/secrets/db_password + volumes: + - "db:/var/lib/postgresql/data" + +volumes: + core: + web: + db: + +secrets: + db_password: + external: true + name: ${STACK_NAME}_db_root_password_${DB_ROOT_PASSWORD_VERSION} + +configs: + entrypoint_conf: + name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION} + file: entrypoint.sh.tmpl + template_driver: golang diff --git a/entrypoint.sh.tmpl b/entrypoint.sh.tmpl new file mode 100644 index 0000000..a9bf588 --- /dev/null +++ b/entrypoint.sh.tmpl @@ -0,0 +1 @@ +#!/bin/bash