first commit
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user