first commit
This commit is contained in:
49
modules/20-services-apps/actualbudget/main.tf
Normal file
49
modules/20-services-apps/actualbudget/main.tf
Normal file
@@ -0,0 +1,49 @@
|
||||
// ActualBudget module for budgeting
|
||||
// This module configures an ActualBudget container with the specified volumes
|
||||
|
||||
locals {
|
||||
container_name = var.container_name != "" ? var.container_name : "actualbudget"
|
||||
image_tag = var.image_tag != "" ? var.image_tag : "latest"
|
||||
|
||||
default_env_vars = {
|
||||
TZ = var.timezone
|
||||
PUID = var.puid
|
||||
PGID = var.pgid
|
||||
}
|
||||
|
||||
default_volumes = [
|
||||
{
|
||||
container_path = "/data"
|
||||
host_path = var.data_volume_path
|
||||
read_only = false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
module "actualbudget" {
|
||||
source = "../../10-services-generic/docker-service"
|
||||
|
||||
container_name = var.container_name
|
||||
image = "actualbudget/actual-server"
|
||||
tag = var.image_tag
|
||||
|
||||
// Environment variables
|
||||
env_vars = local.default_env_vars
|
||||
|
||||
// Port mapping
|
||||
ports = [
|
||||
{
|
||||
internal = 5006
|
||||
external = var.port
|
||||
protocol = "tcp"
|
||||
}
|
||||
]
|
||||
|
||||
// Volume mapping
|
||||
volumes = local.default_volumes
|
||||
|
||||
// Enable monitoring for the container via Watchtower
|
||||
monitoring = var.monitoring
|
||||
|
||||
networks = var.networks
|
||||
}
|
||||
24
modules/20-services-apps/actualbudget/outputs.tf
Normal file
24
modules/20-services-apps/actualbudget/outputs.tf
Normal file
@@ -0,0 +1,24 @@
|
||||
output "container_name" {
|
||||
description = "The name of the ActualBudget container"
|
||||
value = module.actualbudget.container_name
|
||||
}
|
||||
|
||||
output "container_id" {
|
||||
description = "The ID of the ActualBudget container"
|
||||
value = module.actualbudget.container_id
|
||||
}
|
||||
|
||||
output "image_id" {
|
||||
description = "The ID of the ActualBudget image"
|
||||
value = module.actualbudget.image_id
|
||||
}
|
||||
|
||||
output "ip_address" {
|
||||
description = "The IP address of the ActualBudget container"
|
||||
value = module.actualbudget.ip_address
|
||||
}
|
||||
|
||||
output "local_url" {
|
||||
description = "The local URL to access the ActualBudget interface"
|
||||
value = "http://localhost:${var.port}"
|
||||
}
|
||||
52
modules/20-services-apps/actualbudget/variables.tf
Normal file
52
modules/20-services-apps/actualbudget/variables.tf
Normal file
@@ -0,0 +1,52 @@
|
||||
variable "container_name" {
|
||||
description = "Name of the ActualBudget container"
|
||||
type = string
|
||||
default = "actualbudget"
|
||||
}
|
||||
|
||||
variable "timezone" {
|
||||
description = "Timezone for the container"
|
||||
type = string
|
||||
default = "UTC"
|
||||
}
|
||||
|
||||
variable "image_tag" {
|
||||
description = "Tag of the ActualBudget image to use"
|
||||
type = string
|
||||
default = "latest"
|
||||
}
|
||||
|
||||
variable "port" {
|
||||
description = "External port for ActualBudget server"
|
||||
type = number
|
||||
default = 5006
|
||||
}
|
||||
|
||||
variable "data_volume_path" {
|
||||
description = "Host path for ActualBudget data volume"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "puid" {
|
||||
description = "User ID for the container"
|
||||
type = number
|
||||
default = 1000
|
||||
}
|
||||
|
||||
variable "pgid" {
|
||||
description = "Group ID for the container"
|
||||
type = number
|
||||
default = 1000
|
||||
}
|
||||
|
||||
variable "monitoring" {
|
||||
description = "Enable monitoring for the container via Watchtower"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "networks" {
|
||||
description = "List of networks to which the container should be attached"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
70
modules/20-services-apps/emulatorjs/main.tf
Normal file
70
modules/20-services-apps/emulatorjs/main.tf
Normal file
@@ -0,0 +1,70 @@
|
||||
// EmulatorJS module for retro game emulation
|
||||
// This module configures an EmulatorJS container with the specified volumes
|
||||
|
||||
locals {
|
||||
container_name = var.container_name != "" ? var.container_name : "emulatorjs"
|
||||
image_tag = var.image_tag != "" ? var.image_tag : "latest"
|
||||
|
||||
default_env_vars = {
|
||||
TZ = var.timezone
|
||||
}
|
||||
|
||||
// Merge default env vars with any additional ones provided
|
||||
env_vars = merge(local.default_env_vars, var.additional_env_vars)
|
||||
|
||||
// Default volumes for EmulatorJS
|
||||
default_volumes = [
|
||||
{
|
||||
host_path = var.config_volume_path
|
||||
container_path = "/config"
|
||||
read_only = false
|
||||
},
|
||||
{
|
||||
host_path = var.data_volume_path
|
||||
container_path = "/data"
|
||||
read_only = false
|
||||
}
|
||||
]
|
||||
|
||||
// Merge default volumes with any additional ones provided
|
||||
volumes = concat(local.default_volumes, var.additional_volumes)
|
||||
}
|
||||
|
||||
// Use the generic docker-service module to deploy EmulatorJS
|
||||
module "emulatorjs" {
|
||||
source = "../../10-services-generic/docker-service"
|
||||
|
||||
container_name = local.container_name
|
||||
image = "linuxserver/emulatorjs"
|
||||
tag = local.image_tag
|
||||
|
||||
restart_policy = var.restart_policy
|
||||
network_mode = "bridge"
|
||||
|
||||
env_vars = local.env_vars
|
||||
volumes = local.volumes
|
||||
|
||||
labels = var.labels
|
||||
|
||||
// Default ports for EmulatorJS
|
||||
ports = [
|
||||
{
|
||||
internal = 3000
|
||||
external = var.config_port
|
||||
protocol = "tcp"
|
||||
},
|
||||
{
|
||||
internal = 80
|
||||
external = var.frontend_port
|
||||
protocol = "tcp"
|
||||
},
|
||||
{
|
||||
internal = 4001
|
||||
external = var.backend_port
|
||||
protocol = "tcp"
|
||||
}
|
||||
]
|
||||
|
||||
// Enable monitoring for the container via Watchtower
|
||||
monitoring = var.monitoring
|
||||
}
|
||||
26
modules/20-services-apps/emulatorjs/outputs.tf
Normal file
26
modules/20-services-apps/emulatorjs/outputs.tf
Normal file
@@ -0,0 +1,26 @@
|
||||
// Outputs for the EmulatorJS module
|
||||
|
||||
output "container_name" {
|
||||
description = "Name of the created EmulatorJS container"
|
||||
value = module.emulatorjs.container_name
|
||||
}
|
||||
|
||||
output "container_id" {
|
||||
description = "ID of the created EmulatorJS container"
|
||||
value = module.emulatorjs.container_id
|
||||
}
|
||||
|
||||
output "image_id" {
|
||||
description = "ID of the EmulatorJS image used"
|
||||
value = module.emulatorjs.image_id
|
||||
}
|
||||
|
||||
output "frontend_url" {
|
||||
description = "URL to access the EmulatorJS frontend interface"
|
||||
value = "http://localhost:${var.frontend_port}"
|
||||
}
|
||||
|
||||
output "config_url" {
|
||||
description = "URL to access the EmulatorJS web configuration interface"
|
||||
value = "http://localhost:${var.config_port}"
|
||||
}
|
||||
91
modules/20-services-apps/emulatorjs/variables.tf
Normal file
91
modules/20-services-apps/emulatorjs/variables.tf
Normal file
@@ -0,0 +1,91 @@
|
||||
variable "container_name" {
|
||||
description = "Name for the EmulatorJS container"
|
||||
type = string
|
||||
default = "emulatorjs"
|
||||
}
|
||||
|
||||
variable "image_tag" {
|
||||
description = "The tag for the EmulatorJS container image"
|
||||
type = string
|
||||
default = "latest"
|
||||
}
|
||||
|
||||
variable "restart_policy" {
|
||||
description = "Restart policy for the container"
|
||||
type = string
|
||||
default = "unless-stopped"
|
||||
}
|
||||
|
||||
variable "timezone" {
|
||||
description = "Timezone for the container"
|
||||
type = string
|
||||
default = "Etc/UTC"
|
||||
}
|
||||
|
||||
variable "puid" {
|
||||
description = "User ID the container will run as"
|
||||
type = number
|
||||
default = 1000
|
||||
}
|
||||
|
||||
variable "pgid" {
|
||||
description = "Group ID the container will run as"
|
||||
type = number
|
||||
default = 1000
|
||||
}
|
||||
|
||||
variable "config_volume_path" {
|
||||
description = "Host path for the EmulatorJS config directory"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "data_volume_path" {
|
||||
description = "Host path for the EmulatorJS data directory"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "frontend_port" {
|
||||
description = "External port for the EmulatorJS frontend"
|
||||
type = number
|
||||
default = 3000
|
||||
}
|
||||
|
||||
variable "config_port" {
|
||||
description = "External port for the EmulatorJS configuration interface"
|
||||
type = number
|
||||
default = 8080
|
||||
}
|
||||
|
||||
variable "backend_port" {
|
||||
description = "External port for the EmulatorJS backend"
|
||||
type = number
|
||||
default = 4001
|
||||
}
|
||||
|
||||
variable "additional_env_vars" {
|
||||
description = "Additional environment variables for EmulatorJS"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "additional_volumes" {
|
||||
description = "Additional volumes to mount in the container"
|
||||
type = list(object({
|
||||
host_path = string
|
||||
container_path = string
|
||||
read_only = bool
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
description = "Labels to set on the container"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "monitoring" {
|
||||
description = "Enable monitoring for the container via Watchtower"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
79
modules/20-services-apps/watchtower/README.md
Normal file
79
modules/20-services-apps/watchtower/README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Watchtower Module
|
||||
|
||||
This module deploys a Watchtower container which automatically updates your running Docker containers when new images become available.
|
||||
|
||||
## Features
|
||||
|
||||
- Automatic updates for Docker containers
|
||||
- Configurable update schedule
|
||||
- Optional cleanup of old images
|
||||
- Notification support via shoutrrr
|
||||
- Container monitoring options
|
||||
|
||||
## Usage
|
||||
|
||||
To use this module in your root module, add the following code:
|
||||
|
||||
```hcl
|
||||
module "watchtower" {
|
||||
source = "./modules/20-services-apps/watchtower"
|
||||
|
||||
# Basic configuration
|
||||
container_name = "watchtower"
|
||||
image_tag = "latest"
|
||||
timezone = "Australia/Sydney"
|
||||
|
||||
# Update settings
|
||||
poll_interval = 86400 # Check once per day (in seconds)
|
||||
cleanup = true # Remove old images after updating
|
||||
rolling_restart = true # Update containers one by one
|
||||
|
||||
# Optional notification settings
|
||||
enable_notifications = false
|
||||
# notification_url = "discord://webhook-id/webhook-token"
|
||||
|
||||
# Additional settings as needed
|
||||
# additional_env_vars = {
|
||||
# WATCHTOWER_MONITOR_ONLY = "true"
|
||||
# }
|
||||
}
|
||||
```
|
||||
|
||||
## Required Resources
|
||||
|
||||
This module leverages the generic `docker-service` module, which handles the Docker container deployment.
|
||||
|
||||
## Input Variables
|
||||
|
||||
| Name | Description | Type | Default |
|
||||
|------|-------------|------|---------|
|
||||
| container_name | Name for the Watchtower container | string | "watchtower" |
|
||||
| image_tag | The tag for the Watchtower container image | string | "latest" |
|
||||
| restart_policy | Restart policy for the container | string | "unless-stopped" |
|
||||
| timezone | Timezone for the container | string | "Etc/UTC" |
|
||||
| cleanup | Remove old images after updating | bool | true |
|
||||
| poll_interval | Poll interval (in seconds) for checking updates | number | 86400 |
|
||||
| include_stopped | Include stopped containers when checking for updates | bool | false |
|
||||
| revive_stopped | Restart stopped containers after updating | bool | false |
|
||||
| rolling_restart | Restart containers one by one instead of all at once | bool | true |
|
||||
| notification_url | URL for sending update notifications via shoutrrr | string | "" |
|
||||
| enable_notifications | Enable shoutrrr notifications | bool | false |
|
||||
| additional_env_vars | Additional environment variables for Watchtower | map(string) | {} |
|
||||
| additional_volumes | Additional volumes to mount in the container | list(object) | [] |
|
||||
| labels | Labels to set on the container | map(string) | {} |
|
||||
| ports | Ports to expose (rarely needed for Watchtower) | list(object) | [] |
|
||||
| monitoring | Enable monitoring for the container | bool | true |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| container_name | Name of the created Watchtower container |
|
||||
| container_id | ID of the created Watchtower container |
|
||||
| image_id | ID of the Watchtower image used |
|
||||
|
||||
## Notes
|
||||
|
||||
- Watchtower needs access to the Docker socket to monitor and update containers
|
||||
- For security-conscious environments, consider limiting which containers Watchtower can update
|
||||
- See the [Watchtower documentation](https://containrrr.dev/watchtower/) for more advanced configuration options
|
||||
58
modules/20-services-apps/watchtower/main.tf
Normal file
58
modules/20-services-apps/watchtower/main.tf
Normal file
@@ -0,0 +1,58 @@
|
||||
// Watchtower module for automatic Docker container updates
|
||||
// This module configures a Watchtower container that monitors and updates other containers
|
||||
|
||||
locals {
|
||||
container_name = var.container_name != "" ? var.container_name : "watchtower"
|
||||
image_tag = var.image_tag != "" ? var.image_tag : "latest"
|
||||
|
||||
default_env_vars = {
|
||||
TZ = var.timezone
|
||||
WATCHTOWER_CLEANUP = var.cleanup
|
||||
WATCHTOWER_POLL_INTERVAL = var.poll_interval
|
||||
WATCHTOWER_INCLUDE_STOPPED = var.include_stopped
|
||||
WATCHTOWER_REVIVE_STOPPED = var.revive_stopped
|
||||
WATCHTOWER_ROLLING_RESTART = var.rolling_restart
|
||||
WATCHTOWER_NOTIFICATION_URL = var.notification_url
|
||||
WATCHTOWER_NOTIFICATIONS = var.enable_notifications ? "shoutrrr" : ""
|
||||
}
|
||||
|
||||
// Merge default env vars with any additional ones provided
|
||||
env_vars = merge(local.default_env_vars, var.additional_env_vars)
|
||||
|
||||
// Default volumes for Docker socket access
|
||||
default_volumes = [
|
||||
{
|
||||
host_path = "/var/run/docker.sock"
|
||||
container_path = "/var/run/docker.sock"
|
||||
read_only = true
|
||||
}
|
||||
]
|
||||
|
||||
// Merge default volumes with any additional ones provided
|
||||
volumes = concat(local.default_volumes, var.additional_volumes)
|
||||
}
|
||||
|
||||
// Use the generic docker-service module to deploy Watchtower
|
||||
module "watchtower" {
|
||||
source = "../../10-services-generic/docker-service"
|
||||
|
||||
container_name = local.container_name
|
||||
image = "containrrr/watchtower"
|
||||
tag = local.image_tag
|
||||
|
||||
restart_policy = var.restart_policy
|
||||
network_mode = "bridge"
|
||||
|
||||
env_vars = local.env_vars
|
||||
volumes = local.volumes
|
||||
|
||||
labels = var.labels
|
||||
|
||||
// Watchtower doesn't typically expose ports but we'll include the option
|
||||
ports = var.ports
|
||||
|
||||
// Add monitoring label if enabled
|
||||
monitoring = var.monitoring
|
||||
|
||||
depends_on = []
|
||||
}
|
||||
14
modules/20-services-apps/watchtower/outputs.tf
Normal file
14
modules/20-services-apps/watchtower/outputs.tf
Normal file
@@ -0,0 +1,14 @@
|
||||
output "container_name" {
|
||||
description = "Name of the created Watchtower container"
|
||||
value = module.watchtower.container_name
|
||||
}
|
||||
|
||||
output "container_id" {
|
||||
description = "ID of the created Watchtower container"
|
||||
value = module.watchtower.container_id
|
||||
}
|
||||
|
||||
output "image_id" {
|
||||
description = "ID of the Watchtower image used"
|
||||
value = module.watchtower.image_id
|
||||
}
|
||||
103
modules/20-services-apps/watchtower/variables.tf
Normal file
103
modules/20-services-apps/watchtower/variables.tf
Normal file
@@ -0,0 +1,103 @@
|
||||
variable "container_name" {
|
||||
description = "Name for the Watchtower container"
|
||||
type = string
|
||||
default = "watchtower"
|
||||
}
|
||||
|
||||
variable "image_tag" {
|
||||
description = "The tag for the Watchtower container image"
|
||||
type = string
|
||||
default = "latest"
|
||||
}
|
||||
|
||||
variable "restart_policy" {
|
||||
description = "Restart policy for the container"
|
||||
type = string
|
||||
default = "unless-stopped"
|
||||
}
|
||||
|
||||
variable "timezone" {
|
||||
description = "Timezone for the container"
|
||||
type = string
|
||||
default = "Etc/UTC"
|
||||
}
|
||||
|
||||
variable "cleanup" {
|
||||
description = "Remove old images after updating"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "poll_interval" {
|
||||
description = "Poll interval (in seconds) for checking for updates"
|
||||
type = number
|
||||
default = 86400 // Default: check once per day
|
||||
}
|
||||
|
||||
variable "include_stopped" {
|
||||
description = "Include stopped containers when checking for updates"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "revive_stopped" {
|
||||
description = "Restart stopped containers after updating"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "rolling_restart" {
|
||||
description = "Restart containers one by one instead of all at once"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "notification_url" {
|
||||
description = "URL for sending update notifications via shoutrrr"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "enable_notifications" {
|
||||
description = "Enable shoutrrr notifications"
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "additional_env_vars" {
|
||||
description = "Additional environment variables for Watchtower"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "additional_volumes" {
|
||||
description = "Additional volumes to mount in the container"
|
||||
type = list(object({
|
||||
host_path = string
|
||||
container_path = string
|
||||
read_only = bool
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
description = "Labels to set on the container"
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "ports" {
|
||||
description = "Ports to expose (Watchtower typically doesn't need ports exposed)"
|
||||
type = list(object({
|
||||
internal = number
|
||||
external = number
|
||||
protocol = string
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "monitoring" {
|
||||
description = "Enable monitoring for the container"
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
Reference in New Issue
Block a user