SUI auto discovery
Tiny Go program to automatically add apps to the SUI apps section by using Docker labels
How it works
The Go binary does the following:
- Fetch all containers from the Docker socket
- Look for containers with sui.app.xxx labels
- Write these labels to the JSON config file used by SUI.
Deployment
- Install Docker Compose
- Clone the repository
- Run
docker-compose up -d
. The docker-compose.yml
includes SUI as well.
- Attach labels to containers to be added to the apps section as instructed here.
- Go to
localhost:4000
Container labels
For now only containers can be automatically added to the 'apps' section. To do so, attach the following labels (and label values) to your container:
sui.app.icon=< Material Design icon to display>
See: materialdesignicons.com
sui.app.name=<name to display>
sui.app.url=<url to display>
examples:
docker run -d \
--name nginx \
--label "sui.app.icon=web" \
--label "sui.app.name=nginx" \
--label "sui.app.url=nginx.mydomain.xyz" \
nginx
version: "3.5"
services:
nginx:
image: nginx
container_name: nginx
ports:
- "80:80"
labels:
- "sui.app.icon=web"
- "sui.app.name=nginx"
- "sui.app.url=nginx.mydomain.xyz"
Flags
apps-config
: Location of apps.json file (default "/config/apps.json")
Security
To discover labels attached to containers, the Docker Socket has to be reachable.
This is a security risk.
To mitigate the risk, one could put a proxy in front of the Docker Socket. This has security implications as well, as the proxy container has to be trusted. And this container might be more complicated than my code.
If you are currently already using a Docker Socket proxy, I would advise to use the proxy for sui-auto-discovery as well: see docker-compose-with-proxy.yml
for an example.
If not using a Docker Socket proxy already, I would advise to run the container directly (i.e. without a proxy), as introducing a (potentially complicated) proxy has security implications as well. (i.e. you have to decide who you trust more, sui-auto-discovery vs. the proxy)