Forgejo rework

This commit is contained in:
Greyscale 2025-02-14 20:53:37 +01:00
parent 3fb5e020d9
commit 5db8662a66
Signed by: grey
GPG key ID: DDB392AE64B32D89
6 changed files with 68 additions and 51 deletions

View file

@ -8,52 +8,62 @@ module "forgejo_actions_runner" {
parallelism = var.parallelism parallelism = var.parallelism
converge_enable = false converge_enable = false
environment_variables = { environment_variables = {
forgejo_INSTANCE_URL = var.forgejo_instance_url # forgejo_INSTANCE_URL = var.forgejo_instance_url
forgejo_RUNNER_NAME = var.forgejo_runner_name # forgejo_RUNNER_NAME = var.forgejo_runner_name
forgejo_RUNNER_LABELS = join(",", var.forgejo_runner_labels) # forgejo_RUNNER_LABELS = join(",", var.forgejo_runner_labels)
forgejo_RUNNER_REGISTRATION_TOKEN = var.forgejo_token # forgejo_RUNNER_REGISTRATION_TOKEN = var.forgejo_token
CONFIG_FILE = "/config.yaml" # CONFIG_FILE = "/config.yaml"
#DOCKER_HOST = module.docker_socket_proxy.endpoint
} }
mounts = { "/var/run/docker.sock" = "/var/run/docker.sock" } mounts = {
"/var/run/docker.sock" = "/var/run/docker.sock"
}
networks = var.networks
command = ["/bin/bash", "/entrypoint.sh"]
restart_delay = "1m"
configs = { configs = {
forgejo-config = yamlencode({ "/entrypoint.sh" = <<EOF
name_prefix = ["forgejo-config", var.stack_name, var.service_name] #!/bin/bash
path = "/config.yaml" set -xe
contents = yamlencode({ echo "Configuring runner..."
log = { /bin/forgejo-runner --config /config.yaml register --no-interactive --instance "${var.forgejo_instance_url}" --name ${var.forgejo_runner_name} --token ${var.forgejo_token}
level = "info" echo "Starting runner..."
} exec /bin/forgejo-runner --config /config.yaml daemon
runner = { EOF
file = ".runner" "/config.yaml" = yamlencode({
capacity = 2 log = {
env_file = ".env" level = "info"
timeout = "3h" }
insecure = false runner = {
fetch_timeout = "5s" file = ".runner"
fetch_interval = "2s" capacity = 2
labels = var.forgejo_runner_labels env_file = ".env"
} timeout = "3h"
cache = { insecure = false
enabled = true fetch_timeout = "5s"
dir = "" fetch_interval = "2s"
host = "" labels = var.forgejo_runner_labels
port = 0 }
external_server = "" cache = {
} enabled = true
container = { dir = ""
network = null host = ""
privileged = false port = 0
options = null external_server = ""
workdir_parent = null }
valid_volumes = [] container = {
docker_host = "" network = null
force_pull = true privileged = false
force_rebuild = false options = null
} workdir_parent = null
host = { valid_volumes = []
workdir_parent : null docker_host = ""
} force_pull = true
}) force_rebuild = false
}
host = {
workdir_parent : null
}
}) })
} }
} }

View file

@ -9,10 +9,18 @@ variable "forgejo_actions_runner_image" {
description = "The docker image to use for the forgejo runner service." description = "The docker image to use for the forgejo runner service."
} }
variable "forgejo_actions_runner_version" { variable "forgejo_actions_runner_version" {
default = "latest" default = "6"
type = string type = string
description = "The version of the docker image to use for the forgejo runner service." description = "The version of the docker image to use for the forgejo runner service."
} }
variable "networks" {
type = list(object({
name = string
id = string
}))
default = []
description = "A list of network names to attach the service to."
}
variable "parallelism" { variable "parallelism" {
description = "The number of instances of the runner to run" description = "The number of instances of the runner to run"
type = number type = number
@ -52,6 +60,7 @@ variable "service_name" {
variable "stack_name" { variable "stack_name" {
type = string type = string
description = "The name of the stack to deploy the service to." description = "The name of the stack to deploy the service to."
default = "forgejo"
} }
variable "placement_constraints" { variable "placement_constraints" {
default = [] default = []

View file

@ -2,8 +2,7 @@ module "postgres" {
source = "../../../products/postgres" source = "../../../products/postgres"
stack_name = var.stack_name stack_name = var.stack_name
placement_constraints = var.placement_constraints placement_constraints = var.placement_constraints
postgres_version = "15" networks = [module.network]
networks = [module.forgejo_network]
data_persist_path = var.database_storage_path data_persist_path = var.database_storage_path
ports = [ ports = [
{ {

View file

@ -5,7 +5,7 @@ module "forgejo" {
stack_name = var.stack_name stack_name = var.stack_name
service_name = "forgejo" service_name = "forgejo"
placement_constraints = var.placement_constraints placement_constraints = var.placement_constraints
networks = concat(var.networks, [module.forgejo_network]) networks = concat(var.networks, [module.network])
configs = { configs = {
"/data/gitea/conf/app.ini" = templatefile("${path.module}/app.ini.tpl", merge({ "/data/gitea/conf/app.ini" = templatefile("${path.module}/app.ini.tpl", merge({
name = var.forgejo_name name = var.forgejo_name

View file

@ -1,4 +1,4 @@
module "forgejo_network" { module "network" {
source = "../../../docker/network" source = "../../../docker/network"
stack_name = var.stack_name stack_name = var.stack_name
network_name = "forgejo" network_name = "forgejo"

View file

@ -4,10 +4,9 @@ output "docker_service" {
output "postgres" { output "postgres" {
value = module.postgres value = module.postgres
} }
output "endpoint" { output "endpoint" {
value = module.forgejo.endpoint value = module.forgejo.endpoint
} }
output "network" { output "network" {
value = module.forgejo_network.network value = module.network.network
} }