From 5cd8d36d97a1123f186640c1832bc052f7338e6f Mon Sep 17 00:00:00 2001 From: Yuris Cakranegara Date: Sat, 28 Jun 2025 13:04:30 +1000 Subject: [PATCH] feat: add glance --- modules/20-services-apps/glance/README.md | 77 +++++++++++++++++++++++ modules/20-services-apps/glance/main.tf | 52 +++++++++++++++ services/main.tf | 6 ++ services/outputs.tf | 1 + 4 files changed, 136 insertions(+) create mode 100644 modules/20-services-apps/glance/README.md create mode 100644 modules/20-services-apps/glance/main.tf diff --git a/modules/20-services-apps/glance/README.md b/modules/20-services-apps/glance/README.md new file mode 100644 index 0000000..f5800ff --- /dev/null +++ b/modules/20-services-apps/glance/README.md @@ -0,0 +1,77 @@ +# Glance Module + +This module deploys [Glance](https://glanceapp.io/), a dashboard application, as a Docker container in the homelab environment. + +## Overview + +The Glance module: + +- Deploys the `glanceapp/glance` Docker container +- Persists configuration to a volume on the host +- Provides service definition for integration with networking modules + +## Usage + +```hcl +module "glance" { + source = "./modules/20-services-apps/glance" + volume_path = "/path/to/volumes/glance" + networks = ["homelab-network"] +} +``` + +## Variables + +| Variable | Description | Type | Default | +| ------------- | ---------------------------------------------------------- | -------------- | ---------- | +| `image_tag` | Tag of the Glance image to use | `string` | `"latest"` | +| `volume_path` | Host path for Glance data volume | `string` | - | +| `networks` | List of networks to which the container should be attached | `list(string)` | - | + +## Outputs + +| Output | Description | +| -------------------- | ---------------------------------------------------------- | +| `service_definition` | Service definition for integration with networking modules | + +## Service Definition + +This module outputs a service definition that is used by the networking modules to expose the service. + +```hcl +{ + name = "glance" + primary_port = 4921 + endpoint = "http://glance:4921" + subdomains = ["glance"] + publish_via = "tunnel" # Only publish through Cloudflare tunnel +} +``` + +## Data Persistence + +Glance stores its configuration in the `/app/config` directory inside the container. This is mapped to a volume on the host at `${volume_path}/config`. + +## Integration with Networking Modules + +This service is configured to be exposed through a Cloudflare tunnel for secure remote access, set by `publish_via = "tunnel"`. + +## Example Integration in Main Configuration + +```hcl +module "glance" { + source = "./modules/20-services-apps/glance" + volume_path = module.system_globals.volume_host + networks = [module.services.homelab_docker_network_name] +} + +# The service definition is automatically included in the services output +module "services" { + source = "./modules/services" + # ... + service_definitions = [ + module.glance.service_definition, + # Other service definitions + ] +} +``` diff --git a/modules/20-services-apps/glance/main.tf b/modules/20-services-apps/glance/main.tf new file mode 100644 index 0000000..4a5faeb --- /dev/null +++ b/modules/20-services-apps/glance/main.tf @@ -0,0 +1,52 @@ +variable "image_tag" { + description = "Tag of the Glance image to use" + type = string + default = "latest" +} + +variable "volume_path" { + description = "Host path for Glance data volume" + type = string +} + +variable "networks" { + description = "List of networks to which the container should be attached" + type = list(string) +} + +locals { + container_name = "glance" + image = "glanceapp/glance" + image_tag = var.image_tag != "" ? var.image_tag : "latest" + monitoring = true + host_port = 8080 + subdomains = ["glance"] + default_volumes = [ + { + container_path = "/app/config" + host_path = "${var.volume_path}/config" + read_only = false + }, + ] +} + +module "glance" { + source = "../../10-services-generic/docker-service" + container_name = local.container_name + image = local.image + tag = local.image_tag + volumes = local.default_volumes + networks = var.networks + monitoring = local.monitoring +} + +output "service_definition" { + description = "General service definition with optional ingress configuration" + value = { + name = local.container_name + primary_port = local.host_port + endpoint = "http://${local.container_name}:${local.host_port}" + subdomains = local.subdomains + publish_via = "tunnel" + } +} diff --git a/services/main.tf b/services/main.tf index b29c729..caad2a3 100644 --- a/services/main.tf +++ b/services/main.tf @@ -41,6 +41,12 @@ module "emulatorjs" { volume_path = "${local.volume_host}/emulatorjs" } +module "glance" { + source = "${local.module_dir}/20-services-apps/glance" + volume_path = "${local.volume_host}/glance" + networks = [module.homelab_docker_network.name] +} + module "linkwarden" { source = "${local.module_dir}/20-services-apps/linkwarden" volume_path = "${local.volume_host}/linkwarden" diff --git a/services/outputs.tf b/services/outputs.tf index 20b3f6e..4187415 100644 --- a/services/outputs.tf +++ b/services/outputs.tf @@ -8,6 +8,7 @@ output "service_definitions" { module.affine.service_definition, module.calibre.service_definition, module.emulatorjs.service_definition, + module.glance.service_definition, module.linkwarden.service_definition, module.ntfy.service_definition, module.pterodactyl_wings.service_definition,