mirror of
				https://github.com/gethomepage/homepage.git
				synced 2025-11-04 03:27:02 -05:00 
			
		
		
		
	Enhancement: Add service discovery labels support for multiple homepage instances (#2340)
This commit is contained in:
		
							parent
							
								
									5bf6f30e2b
								
							
						
					
					
						commit
						6d21ea9ba3
					
				@ -201,6 +201,22 @@ In order to detect every service within the Docker swarm it is necessary that se
 | 
			
		||||
...
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Multiple Homepage Instances
 | 
			
		||||
 | 
			
		||||
The optional field `instanceName` can be configured in [settings.md](settings.md#instance-name) to differentiate between multiple homepage instances.
 | 
			
		||||
 | 
			
		||||
To limit a label to an instance, insert `.instance.{{instanceName}}` after the `homepage` prefix.
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
labels:
 | 
			
		||||
  - homepage.group=Media
 | 
			
		||||
  - homepage.name=Emby
 | 
			
		||||
  - homepage.icon=emby.png
 | 
			
		||||
  - homepage.instance.internal.href=http://emby.lan/
 | 
			
		||||
  - homepage.instance.public.href=https://emby.mydomain.com/
 | 
			
		||||
  - homepage.description=Media server
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Ordering
 | 
			
		||||
 | 
			
		||||
As of v0.6.4 discovered services can include an optional `weight` field to determine sorting such that:
 | 
			
		||||
 | 
			
		||||
@ -404,6 +404,16 @@ or per-service (`services.yaml`) with:
 | 
			
		||||
 | 
			
		||||
If you have both set, the per-service settings take precedence.
 | 
			
		||||
 | 
			
		||||
## Instance Name
 | 
			
		||||
 | 
			
		||||
Name used by automatic docker service discovery to differentiate between multiple homepage instances.
 | 
			
		||||
 | 
			
		||||
For example:
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
instanceName: public
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Hide Widget Error Messages
 | 
			
		||||
 | 
			
		||||
Hide the visible API error messages either globally in `settings.yaml`:
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ import Docker from "dockerode";
 | 
			
		||||
import { CustomObjectsApi, NetworkingV1Api, ApiextensionsV1Api } from "@kubernetes/client-node";
 | 
			
		||||
 | 
			
		||||
import createLogger from "utils/logger";
 | 
			
		||||
import checkAndCopyConfig, { CONF_DIR, substituteEnvironmentVars } from "utils/config/config";
 | 
			
		||||
import checkAndCopyConfig, { CONF_DIR, getSettings, substituteEnvironmentVars } from "utils/config/config";
 | 
			
		||||
import getDockerArguments from "utils/config/docker";
 | 
			
		||||
import getKubeConfig from "utils/config/kubernetes";
 | 
			
		||||
import * as shvl from "utils/config/shvl";
 | 
			
		||||
@ -59,6 +59,8 @@ export async function servicesFromDocker() {
 | 
			
		||||
    return [];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const { instanceName } = getSettings();
 | 
			
		||||
 | 
			
		||||
  const serviceServers = await Promise.all(
 | 
			
		||||
    Object.keys(servers).map(async (serverName) => {
 | 
			
		||||
      try {
 | 
			
		||||
@ -82,6 +84,13 @@ export async function servicesFromDocker() {
 | 
			
		||||
 | 
			
		||||
          Object.keys(containerLabels).forEach((label) => {
 | 
			
		||||
            if (label.startsWith("homepage.")) {
 | 
			
		||||
              let value = label.replace("homepage.", "");
 | 
			
		||||
              if (instanceName && value.startsWith(`instance.${instanceName}.`)) {
 | 
			
		||||
                value = value.replace(`instance.${instanceName}.`, "");
 | 
			
		||||
              } else if (value.startsWith("instance.")) {
 | 
			
		||||
                return;
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
              if (!constructedService) {
 | 
			
		||||
                constructedService = {
 | 
			
		||||
                  container: containerName.replace(/^\//, ""),
 | 
			
		||||
@ -89,11 +98,7 @@ export async function servicesFromDocker() {
 | 
			
		||||
                  type: "service",
 | 
			
		||||
                };
 | 
			
		||||
              }
 | 
			
		||||
              shvl.set(
 | 
			
		||||
                constructedService,
 | 
			
		||||
                label.replace("homepage.", ""),
 | 
			
		||||
                substituteEnvironmentVars(containerLabels[label]),
 | 
			
		||||
              );
 | 
			
		||||
              shvl.set(constructedService, value, substituteEnvironmentVars(containerLabels[label]));
 | 
			
		||||
            }
 | 
			
		||||
          });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user