From ddc7f73a1365cad8178016f3e262d6f54b2ada6a Mon Sep 17 00:00:00 2001 From: moanos Date: Wed, 15 Nov 2023 11:45:10 +0100 Subject: [PATCH] feat: Add slug for multiple domains of same user --- README.md | 5 +++++ roles/static-server/templates/docker-compose.yml.j2 | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 04dabee..ed8fd43 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,16 @@ static_sites: - user: host_1 domain: host_1.example.org key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOREPUBLICKEYINFO host_1" + slug: host-1-staging - user: host_2 domain: host_2.example.org key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMOREPUBLICKEYINFO host_2" + slug: host-1-prod ``` +You can re-use a user and their key. You can also use different keys per user. Be aware that a shared user or keys will allow any such site to alter all sites that share the user/key. + + Now deploy by running ```zsh diff --git a/roles/static-server/templates/docker-compose.yml.j2 b/roles/static-server/templates/docker-compose.yml.j2 index 9bffb77..5bc1307 100644 --- a/roles/static-server/templates/docker-compose.yml.j2 +++ b/roles/static-server/templates/docker-compose.yml.j2 @@ -15,12 +15,12 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=traefik" - - "traefik.http.routers.{{ site.user }}.rule=Host(`{{ site.domain }}`)" - - "traefik.http.routers.{{ site.user }}.service=present" - - "traefik.http.routers.{{ site.user }}.entrypoints=web-secure" - - "traefik.http.routers.{{ site.user }}.tls=true" - - "traefik.http.routers.{{ site.user }}.tls.certResolver=default" - - "traefik.http.services.{{ site.user }}.loadbalancer.server.port=8080" + - "traefik.http.routers.{{ site.slug }}.rule=Host(`{{ site.domain }}`)" + - "traefik.http.routers.{{ site.slug }}.service={{ site.slug }}-service" + - "traefik.http.routers.{{ site.slug }}.entrypoints=web-secure" + - "traefik.http.routers.{{ site.slug }}.tls=true" + - "traefik.http.routers.{{ site.slug }}.tls.certResolver=default" + - "traefik.http.services.{{ site.slug }}-service.loadbalancer.server.port=8080" networks: - traefik {% endfor %}