From c1c96ee08a395c54732cbc78d5eed4efe781c03c Mon Sep 17 00:00:00 2001 From: Simon L Date: Tue, 3 Oct 2023 20:30:46 +0200 Subject: [PATCH] allow to add documentation on containers Signed-off-by: Simon L --- community-containers/caddy/caddy.json | 1 + community-containers/fail2ban/fail2ban.json | 1 + community-containers/pi-hole/pi-hole.json | 1 + community-containers/plex/plex.json | 1 + community-containers/readme.md | 2 +- community-containers/vaultwarden/vaultwarden.json | 1 + php/containers-schema.json | 4 ++++ php/src/Container/Container.php | 7 +++++++ php/src/ContainerDefinitionFetcher.php | 6 ++++++ php/templates/containers.twig | 10 +++++++--- 10 files changed, 30 insertions(+), 4 deletions(-) diff --git a/community-containers/caddy/caddy.json b/community-containers/caddy/caddy.json index 91fceafb..561c5219 100644 --- a/community-containers/caddy/caddy.json +++ b/community-containers/caddy/caddy.json @@ -3,6 +3,7 @@ { "container_name": "nextcloud-aio-caddy", "display_name": "Caddy with geoblocking", + "documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/caddy", "image": "szaimen/aio-caddy", "image_tag": "v1", "internal_port": "443", diff --git a/community-containers/fail2ban/fail2ban.json b/community-containers/fail2ban/fail2ban.json index 1a41a200..5305ad85 100644 --- a/community-containers/fail2ban/fail2ban.json +++ b/community-containers/fail2ban/fail2ban.json @@ -3,6 +3,7 @@ { "container_name": "nextcloud-aio-fail2ban", "display_name": "Fail2ban", + "documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/fail2ban", "image": "szaimen/aio-fail2ban", "image_tag": "v1", "internal_port": "host", diff --git a/community-containers/pi-hole/pi-hole.json b/community-containers/pi-hole/pi-hole.json index a2a6c752..816ac692 100644 --- a/community-containers/pi-hole/pi-hole.json +++ b/community-containers/pi-hole/pi-hole.json @@ -3,6 +3,7 @@ { "container_name": "nextcloud-aio-pihole", "display_name": "Pi-hole", + "documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/pi-hole", "image": "pihole/pihole", "image_tag": "latest", "internal_port": "8573", diff --git a/community-containers/plex/plex.json b/community-containers/plex/plex.json index a0bc5231..168bc4a9 100644 --- a/community-containers/plex/plex.json +++ b/community-containers/plex/plex.json @@ -3,6 +3,7 @@ { "container_name": "nextcloud-aio-plex", "display_name": "Plex", + "documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/plex", "image": "plexinc/pms-docker", "image_tag": "latest", "internal_port": "host", diff --git a/community-containers/readme.md b/community-containers/readme.md index 5c0c800d..b796cd9d 100644 --- a/community-containers/readme.md +++ b/community-containers/readme.md @@ -10,4 +10,4 @@ All containers that are in this directory are community maintained so the respon You might want to add additional community containers to the default AIO stack. You can do so by adding `--env AIO_COMMUNITY_CONTAINERS="container1 container2"` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used) and customize the value to your fitting. It must match the folder names in this directory! ⚠️⚠️⚠️ Please review the folder for documentation on each of the containers before adding them! Not reviewing the documentation for each of them first might break starting the AIO containers because e.g. fail2ban only works on Linux and not on Docker Desktop! ## How to add containers? -Simply submit a PR by creating a new folder in this directory: https://github.com/nextcloud/all-in-one/tree/main/community-containers with the name of your container. It must include a json file with the same name and with correct syntax and a readme.md with additional information. You might get inspired by fail2ban, plex, pi-hole or vaultwarden (subfolders in this directory). For a full-blown example of the json file, see https://github.com/nextcloud/all-in-one/blob/main/php/containers.json. The json-schema that it validates against can be found here: https://github.com/nextcloud/all-in-one/blob/main/php/containers-schema.json. +Simply submit a PR by creating a new folder in this directory: https://github.com/nextcloud/all-in-one/tree/main/community-containers with the name of your container. It must include a json file with the same name and with correct syntax and a readme.md with additional information. You might get inspired by caddy, fail2ban, plex, pi-hole or vaultwarden (subfolders in this directory). For a full-blown example of the json file, see https://github.com/nextcloud/all-in-one/blob/main/php/containers.json. The json-schema that it validates against can be found here: https://github.com/nextcloud/all-in-one/blob/main/php/containers-schema.json. diff --git a/community-containers/vaultwarden/vaultwarden.json b/community-containers/vaultwarden/vaultwarden.json index ae397347..0bacff7a 100644 --- a/community-containers/vaultwarden/vaultwarden.json +++ b/community-containers/vaultwarden/vaultwarden.json @@ -3,6 +3,7 @@ { "container_name": "nextcloud-aio-vaultwarden", "display_name": "Vaultwarden", + "documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/vaultwarden", "image": "vaultwarden/server", "image_tag": "alpine", "internal_port": "8812", diff --git a/php/containers-schema.json b/php/containers-schema.json index 82672e90..0f99c1a9 100644 --- a/php/containers-schema.json +++ b/php/containers-schema.json @@ -108,6 +108,10 @@ "type": "string", "pattern": "^([a-z0-9.-]+|%AIO_CHANNEL%)$" }, + "documentation": { + "type": "string", + "pattern": "^https://.*$" + }, "devices": { "type": "array", "items": { diff --git a/php/src/Container/Container.php b/php/src/Container/Container.php index 30aa1f68..9d598b4a 100644 --- a/php/src/Container/Container.php +++ b/php/src/Container/Container.php @@ -35,6 +35,7 @@ class Container { private bool $init; private string $imageTag; private AioVariables $aioVariables; + private string $documentation; private DockerActionManager $dockerActionManager; public function __construct( @@ -60,6 +61,7 @@ class Container { bool $init, string $imageTag, AioVariables $aioVariables, + string $documentation, DockerActionManager $dockerActionManager ) { $this->identifier = $identifier; @@ -84,6 +86,7 @@ class Container { $this->init = $init; $this->imageTag = $imageTag; $this->aioVariables = $aioVariables; + $this->documentation = $documentation; $this->dockerActionManager = $dockerActionManager; } @@ -193,4 +196,8 @@ class Container { public function GetAioVariables() : AioVariables { return $this->aioVariables; } + + public function GetDocumentation() : string { + return $this->documentation; + } } diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index a246083d..d5f40f8c 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -304,6 +304,11 @@ class ContainerDefinitionFetcher $imageTag = $entry['image_tag']; } + $documentation = ''; + if (isset($entry['documentation'])) { + $documentation = $entry['documentation']; + } + $containers[] = new Container( $entry['container_name'], $displayName, @@ -327,6 +332,7 @@ class ContainerDefinitionFetcher $init, $imageTag, $aioVariables, + $documentation, $this->container->get(DockerActionManager::class) ); } diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 99b5fdca..94756ad5 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -255,15 +255,19 @@ {% for container in containers %} {% if container.GetDisplayName() != '' %}
  • + {% set displayName = container.GetDisplayName() %} + {% if container.GetDocumentation() != '' %} + {% set displayName = '' ~ displayName ~ '' %} + {% endif %} {% if class(container.GetStartingState()) == 'AIO\\Container\\State\\StartingState' %} - {{container.GetDisplayName()}} (Starting) + {{ displayName }} (Starting) {% elseif class(container.GetRunningState()) == 'AIO\\Container\\State\\RunningState' %} - {{container.GetDisplayName()}} (Running) + {{ displayName }} (Running) {% else %} - {{container.GetDisplayName()}} (Stopped) + {{ displayName }} (Stopped) {% endif %}
  • {% endif %}