feat(docker-service): enable custom pguid & uid and extra hosts
This commit is contained in:
@@ -7,7 +7,7 @@ module "system_globals" {
|
|||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
docker = {
|
docker = {
|
||||||
source = "kreuzwerker/docker"
|
source = "kreuzwerker/docker"
|
||||||
}
|
}
|
||||||
dotenv = {
|
dotenv = {
|
||||||
source = "germanbrew/dotenv"
|
source = "germanbrew/dotenv"
|
||||||
@@ -22,8 +22,8 @@ locals {
|
|||||||
|
|
||||||
default_env_vars = {
|
default_env_vars = {
|
||||||
TZ = module.system_globals.timezone
|
TZ = module.system_globals.timezone
|
||||||
PUID = module.system_globals.puid
|
PUID = var.puid != null ? var.puid : module.system_globals.puid
|
||||||
PGID = module.system_globals.pgid
|
PGID = var.pgid != null ? var.pgid : module.system_globals.pgid
|
||||||
}
|
}
|
||||||
|
|
||||||
env_vars = merge(var.env_vars, local.default_env_vars)
|
env_vars = merge(var.env_vars, local.default_env_vars)
|
||||||
@@ -72,6 +72,15 @@ resource "docker_container" "service_container" {
|
|||||||
# Set the network mode (bridge, host, etc.)
|
# Set the network mode (bridge, host, etc.)
|
||||||
network_mode = local.network_mode
|
network_mode = local.network_mode
|
||||||
|
|
||||||
|
# Add host mappings (entries for /etc/hosts)
|
||||||
|
dynamic "host" {
|
||||||
|
for_each = var.host_mappings
|
||||||
|
content {
|
||||||
|
host = host.value.host
|
||||||
|
ip = host.value.ip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Dynamically configure ports based on the provided list
|
# Dynamically configure ports based on the provided list
|
||||||
dynamic "ports" {
|
dynamic "ports" {
|
||||||
for_each = local.ports_config
|
for_each = local.ports_config
|
||||||
|
|||||||
@@ -65,6 +65,18 @@ variable "env_vars" {
|
|||||||
sensitive = true
|
sensitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "puid" {
|
||||||
|
description = "User ID for the container"
|
||||||
|
type = number
|
||||||
|
default = null
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "pgid" {
|
||||||
|
description = "Group ID for the container"
|
||||||
|
type = number
|
||||||
|
default = null
|
||||||
|
}
|
||||||
|
|
||||||
variable "labels" {
|
variable "labels" {
|
||||||
description = "Docker container labels"
|
description = "Docker container labels"
|
||||||
type = map(string)
|
type = map(string)
|
||||||
@@ -77,13 +89,22 @@ variable "monitoring" {
|
|||||||
default = true
|
default = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "host_mappings" {
|
||||||
|
description = "Additional host mappings for the container (/etc/hosts entries)"
|
||||||
|
type = list(object({
|
||||||
|
host = string
|
||||||
|
ip = string
|
||||||
|
}))
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
variable "healthcheck" {
|
variable "healthcheck" {
|
||||||
description = "Container healthcheck configuration"
|
description = "Container healthcheck configuration"
|
||||||
type = object({
|
type = object({
|
||||||
test = list(string)
|
test = list(string)
|
||||||
interval = string
|
interval = string
|
||||||
timeout = string
|
timeout = string
|
||||||
start_period = string
|
start_period = optional(string)
|
||||||
retries = number
|
retries = number
|
||||||
})
|
})
|
||||||
default = null
|
default = null
|
||||||
|
|||||||
Reference in New Issue
Block a user