glance icon indicating copy to clipboard operation
glance copied to clipboard

Feature Request - Docker Label Support

Open samcro1967 opened this issue 1 year ago • 5 comments

Hi,

First off, love the app—amazing work!

I typically avoid apps that require configuration solely through config files. Over time, many such apps I've used change their config formats, leading to "out of date" local config files that need manual updates to stay in sync with the latest version.

I've found a good balance with apps that support using Docker labels. This approach keeps the config file relatively small and easier to manage as new releases become available. Generally, I only need to update "global" options in the config file, while most of my container-specific configurations are handled via Docker labels. This method allows me to add new containers by simply including a few labels in the Docker Compose file, without needing to update another config file manually.

Here are a couple of projects that implement this effectively: Plugsy Caddy-Docker-Proxy

I particularly like how caddy-docker-proxy handles it: you provide a global CaddyFile, it collects the rest of the config from Docker labels, and generates a combined CaddyFile for debugging purposes.

I would appreciate your consideration of this feature in future updates. Keep up the fantastic work!

Best regards

samcro1967 avatar Jun 09 '24 16:06 samcro1967

Hey,

Admittedly I'm not much into DevOps so I'm not familiar with the different use cases for Docker labels. Could you provide some examples of how they could be used by Glance? Is it just to specify different properties of the config from within your docker compose file?

svilenmarkov avatar Jun 11 '24 00:06 svilenmarkov

Great question. I should have been more specific with an example. The example below automatically adds Gitea to the Plugsy dashboard:

    labels:
      - plugsy.name=Gitea
      - plugsy.category=CI/CD Pipeline
      - plugsy.link=http://local.gitea:3069/
      - plugsy.icon=https://docs.gitea.io/images/gitea.png

A similiar approach could be used to automatically add things to a Glance page with either a bookmark or a monitor:

    labels:
      - galnce.page.name=Links
      - glance.widget.type=monitor
      - glance.widget.name=CI/CD Pipeline
      - glance.widget.sites.title=Gitea
      - glance.widget.sites.url=http://local.gitea:3069/
      - glance.widget.sites.icon=https://docs.gitea.io/images/gitea.png

Glance then monitors docker.sock, detects the new labels when the container is created, and automatically add Gitea to the Links page under the sites for the CI/CD Pipeline monitor.

samcro1967 avatar Jun 11 '24 01:06 samcro1967

Thanks for providing some examples!

I'm not sure whether doing this in Glance is very practical as the configuration is fairly deep in terms of nesting and position dependent. With your example from above it's not easy to derive where the widget should get placed - which page, column, order, etc. It would probably have to look more like this, which is quite verbose and ugly:

glance.page[0].name=Links
glance.page[0].columns[0].widgets[0].type=monitor
glance.page[0].columns[0].widgets[0].sites[0].title=Gitea
glance.page[0].columns[0].widgets[0].sites[0].url=http://local.gitea:3069/
glance.page[0].columns[0].widgets[0].sites[0].icon=https://docs.gitea.io/images/gitea.png

svilenmarkov avatar Jun 11 '24 02:06 svilenmarkov

When I have seen this implemented with other apps, there would still be a glance.yml file where the "stub" and manual entries would be added. You would use the labels to determine where the stub is and add them there. You would know which page and widget to add them to from the labels. Order would have to be worked out. Do you just add them at the end, sort alphabetically by default (my preference), add a property to monitor and bookmarks so users can specify order manually themselves, give multiple sorting options, etc.

In the example below, a container would just be added right after the Router entry below with the labels I suggested above.

pages:
  - name: Home
    columns:
      - size: small
        widgets:
          - type: search
            search-engine: google
            bangs:
              - title: YouTube
                shortcut: "!yt"
                url: https://www.youtube.com/results?search_query={QUERY}
          - type: clock
            hour-format: 24h
            timezones:
              - timezone: America/New_York
                label: Eastern
              - timezone: America/Denver
                label: Mountain
              - timezone: America/Los_Angeles
                label: Pacific

          - type: calendar

      - size: full
        widgets:

          - type: rss
            limit: 10
            collapse-after: 3
            cache: 3h
            feeds:
              - url: https://lifehacker.com/rss
                title: Lifehacker
              - url: http://feeds.wired.com/wired/index
                title: Wired

          - type: videos
            channels:
              - UCVy16RS5eEDh8anP8j94G2A # DB Tech

          - type: reddit
            subreddit: selfhosted

      - size: small
        widgets:
          - type: weather
            units: imperial
            hour-format: 12h
            location: Chicago, United States

          - type: markets
            markets:
              - symbol: NDAQ
                name: NASDAQ
              - symbol: ICE
                name: NYSE
              - symbol: SPY
                name: S&P 500
              - symbol: DIA
                name: DJIA

  - name: Links
    columns:
      - size: small
        widgets:
          - type: monitor
            style: dynamic-columns-experimental
            cache: 1m
            title: CI/CD Pipeline
            sites:
              - title: Router
                url: http://192.168.1.1

samcro1967 avatar Jun 11 '24 14:06 samcro1967

Great question. I should have been more specific with an example. The example below automatically adds Gitea to the Plugsy dashboard:

    labels:
      - plugsy.name=Gitea
      - plugsy.category=CI/CD Pipeline
      - plugsy.link=http://local.gitea:3069/
      - plugsy.icon=https://docs.gitea.io/images/gitea.png

A similiar approach could be used to automatically add things to a Glance page with either a bookmark or a monitor:

    labels:
      - galnce.page.name=Links
      - glance.widget.type=monitor
      - glance.widget.name=CI/CD Pipeline
      - glance.widget.sites.title=Gitea
      - glance.widget.sites.url=http://local.gitea:3069/
      - glance.widget.sites.icon=https://docs.gitea.io/images/gitea.png

Glance then monitors docker.sock, detects the new labels when the container is created, and automatically add Gitea to the Links page under the sites for the CI/CD Pipeline monitor.

I've implemented some like this (for Docker containers), checkout this discussion

DVDAndroid avatar Aug 06 '24 09:08 DVDAndroid

I was able to achieve this using dvdandroid/glance-docker-container-ext. My original glance.yml was 950 lines. I was able to remove 362 lines from it and added 72 new lines (multiple copies of the extension for grouping on a new page) for dvdandroid/glance-docker-container-ext config resulting in 660 lines total now. Achieved a reduction of 290 lines of config in glance.yml.

More importantly, this also now allows me now to auto add new containers to the glance dashboard from my docker compose file instead of having to open a second file, glance.yml. Going to close this now as the feature has been implemented via an extension.

I should also note for others who end up here that the extension above is checking to see if the docker container is running and provides a link to get to the service. It is not checking that the container link is available. I use Uptime-Kuma to check site availability for sites I need to ensure are available so I do not need that in Glance also. I was only looking to Glance for Dashboard functionality.

samcro1967 avatar Aug 28 '24 18:08 samcro1967