humanmade / altis-local-server

Local Server module for Altis
https://www.altis-dxp.com/resources/docs/local-server/
17 stars 4 forks source link

Support custom domains across all running instances of Altis local-server #475

Open shadyvb opened 2 years ago

shadyvb commented 2 years ago

Context

Altis recently introduced custom SSL certificate generation capabilities, but with the limitation of supporting custom (sub)domains for one running instance, mainly the last one that invokes the generation process, because that one has access to custom domains set in that project configuration, but not to custom domains configured in any other running instance.

The only reason this process would work with non-custom (sub)domains on other instances, is that we always include *.altis.dev which is the default domain name for Altis local-server.

Solution

Step 1 - Expose custom domains

Since we don't have access to Altis configuration of other projects, we'll need all projects to announce the domains they use so any instance with access to Docker can aggregate all the custom domains used by all running instances.

The initial work has prepped for this, so Altis now attaches custom domains used by each container via a label called traefik.domain, in a comma-separated format.

Step 2 - Collect custom domains from all running instances

Querying the label referenced to above can be done via something like: docker ps -q --filter 'label=traefik.domain' | xargs -I{} docker inspect {} --format='{{index .Config.Labels "traefik.domain"}}'

That queries all instances with traefik.domain label, and aggregates it, so it can be parsed and use while generating the SSL certificate Traefik uses for all instances ( hint: only one traefik instance manages connections to ALL running local-server instances ).

We might need to offload the SSL generation process to Traefik itself, so we don't generate different certificates within each local-server instance while it's the generic Traefik instance that uses it.. needs a bit more research on the best approach.

Step 3 - Generating the SSL certificate

That should be straight-forward once the domains are there, using the same commands that's being used now.

Acceptance criteria

Testing steps

veselala commented 2 years ago

Hey team! Please add your planning poker estimate with ZenHub @mikelittle @robindevitt @roborourke @shadyvb

veselala commented 2 years ago

@shadyvb will add some documentation and testing steps