Add wings to modules

This commit is contained in:
2025-10-18 13:33:04 +00:00
parent c030bd1beb
commit 598191f869
6 changed files with 148 additions and 54 deletions
@@ -8,11 +8,8 @@ terraform {
locals {
container_name = "pelican"
wings_container_name = "pelican-wings"
pelican_image = "ghcr.io/pelican-dev/panel"
pelican_wings_image = "ghcr.io/pelican-dev/wings"
pelican_tag = var.image_tag
pelican_wings_tag = var.wings_image_tag
env_file = "${path.module}/.env"
pelican_internal_port = 8000
@@ -60,22 +57,14 @@ resource "local_file" "pelican_config_file" {
filename = "${var.volume_path}/${local.container_name}/.env"
}
module "pelican_network" {
source = "../../01-networking/network-service"
name = "pelican-network"
subnet = "172.16.0.8/29"
driver = "bridge"
options = {
"isolate": false
}
}
module "pelican-panel" {
source = "../../10-generic/docker-service"
container_name = local.container_name
image = local.pelican_image
tag = local.pelican_tag
networks = concat([module.pelican_network.name], var.networks)
networks = var.networks
restart_policy = "always"
volumes = [
{
@@ -100,41 +89,6 @@ module "pelican-panel" {
}
}
module "pelican-wings" {
source = "../../10-generic/docker-service"
container_name = local.wings_container_name
image = local.pelican_wings_image
tag = local.pelican_wings_tag
networks = concat([module.pelican_network.name], var.networks)
restart_policy = "always"
volumes = [
{
host_path = "/run/user/1000/podman/podman.sock"
container_path = "/var/run/docker.sock"
read_only = false
},
{
host_path = "/home/jjvij/.local/share/containers"
container_path = "/var/lib/docker/containers/"
read_only = false
}
]
env_vars = {
TZ = var.timezone
APP_TIMEZONE = var.timezone
WINGS_UID = var.user_id
WINGS_GID = var.group_id
WINGS_USERNAME = "pelican"
}
userns_mode = "keep-id:uid=1000,gid=1000"
labels = {
"run.oci.keep_original_groups" = "1"
}
security_opts = [
"label:type:container_runtype_t"
]
}
output "service_definition" {
description = "General service definition with optional ingress configuration"
value = {
@@ -4,12 +4,6 @@ variable "image_tag" {
default = "latest"
}
variable "wings_image_tag" {
description = "The tag for the Pelican Wings container image. Default: latest"
type = string
default = "latest"
}
variable "volume_path" {
description = "Base directory for volumes"
type = string
@@ -0,0 +1,3 @@
WINGS_0_UUID=
WINGS_0_TOKEN_ID=
WINGS_0_TOKEN=
@@ -0,0 +1,103 @@
terraform {
required_providers {
dotenv = {
source = "germanbrew/dotenv"
}
}
}
locals {
container_name = "pelican-wings"
wings_image = "ghcr.io/pelican-dev/wings"
wings_tag = var.image_tag
env_file = "${path.module}/.env"
internal_port = 8080
wing_0_config = <<-EOT
debug: false
uuid: ${provider::dotenv::get_by_key("WINGS_0_UUID", local.env_file)}
token_id: ${provider::dotenv::get_by_key("WINGS_0_TOKEN_ID", local.env_file)}
token: ${provider::dotenv::get_by_key("WINGS_0_TOKEN", local.env_file)}
api:
host: 0.0.0.0
port: 8080
ssl:
enabled: false
cert: /etc/letsencrypt/live/games.blackchaosnl.myaddr.dev/fullchain.pem
key: /etc/letsencrypt/live/games.blackchaosnl.myaddr.dev/privkey.pem
upload_limit: 256
system:
data: /var/lib/pelican/volumes
sftp:
bind_port: 2022
allowed_mounts: []
remote: 'https://gpanel.blackchaosnl.myaddr.dev'
EOT
}
resource "local_file" "wing_0_config_file" {
content = local.wing_0_config
filename = "${var.volume_path}/${local.container_name}/wing-0-config.yml"
}
module "pelican-wings" {
source = "../../10-generic/docker-service"
container_name = local.container_name
image = local.wings_image
tag = local.wings_tag
networks = var.networks
restart_policy = "always"
ports = [
{
internal = 8080
external = 8080
protocol = "tcp"
},
{
internal = 2022
external = 2022
protocol = "tcp"
}
]
volumes = [
{
host_path = "/run/user/1000/podman/podman.sock"
container_path = "/var/run/docker.sock"
read_only = false
},
{
host_path = "/home/jjvij/.local/share/containers"
container_path = "/var/lib/docker/containers/"
read_only = false
},
{
host_path = "${var.volume_path}/${local.container_name}/wing-0-config.yml"
container_path = "/etc/pelican/config.yml"
read_only = false
}
]
env_vars = {
TZ = var.timezone
APP_TIMEZONE = var.timezone
WINGS_UID = var.user_id
WINGS_GID = var.group_id
WINGS_USERNAME = "pelican"
}
userns_mode = "keep-id:uid=1000,gid=1000"
labels = {
"run.oci.keep_original_groups" = "1"
}
security_opts = [
"label:type:container_runtype_t"
]
}
output "service_definition" {
description = "General service definition with optional ingress configuration"
value = {
name = local.container_name
primary_port = local.internal_port
endpoint = "http://${local.container_name}:${local.internal_port}"
subdomains = ["games"]
}
}
@@ -0,0 +1,34 @@
variable "image_tag" {
description = "The tag for the Pelican Wings container image. Default: latest"
type = string
default = "latest"
}
variable "volume_path" {
description = "Base directory for volumes"
type = string
}
variable "networks" {
description = "List of networks to which the container should be attached"
type = list(string)
default = []
}
variable "user_id" {
description = "User ID for container permissions"
type = string
default = "1000"
}
variable "group_id" {
description = "Group ID for container permissions"
type = string
default = "1000"
}
variable "timezone" {
description = "Timezone for the container"
type = string
default = "Europe/Helsinki"
}