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
converge_enable = false
environment_variables = {
forgejo_INSTANCE_URL = var.forgejo_instance_url
forgejo_RUNNER_NAME = var.forgejo_runner_name
forgejo_RUNNER_LABELS = join(",", var.forgejo_runner_labels)
forgejo_RUNNER_REGISTRATION_TOKEN = var.forgejo_token
CONFIG_FILE = "/config.yaml"
# forgejo_INSTANCE_URL = var.forgejo_instance_url
# forgejo_RUNNER_NAME = var.forgejo_runner_name
# forgejo_RUNNER_LABELS = join(",", var.forgejo_runner_labels)
# forgejo_RUNNER_REGISTRATION_TOKEN = var.forgejo_token
# 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 = {
forgejo-config = yamlencode({
name_prefix = ["forgejo-config", var.stack_name, var.service_name]
path = "/config.yaml"
contents = yamlencode({
log = {
level = "info"
}
runner = {
file = ".runner"
capacity = 2
env_file = ".env"
timeout = "3h"
insecure = false
fetch_timeout = "5s"
fetch_interval = "2s"
labels = var.forgejo_runner_labels
}
cache = {
enabled = true
dir = ""
host = ""
port = 0
external_server = ""
}
container = {
network = null
privileged = false
options = null
workdir_parent = null
valid_volumes = []
docker_host = ""
force_pull = true
force_rebuild = false
}
host = {
workdir_parent : null
}
})
"/entrypoint.sh" = <<EOF
#!/bin/bash
set -xe
echo "Configuring runner..."
/bin/forgejo-runner --config /config.yaml register --no-interactive --instance "${var.forgejo_instance_url}" --name ${var.forgejo_runner_name} --token ${var.forgejo_token}
echo "Starting runner..."
exec /bin/forgejo-runner --config /config.yaml daemon
EOF
"/config.yaml" = yamlencode({
log = {
level = "info"
}
runner = {
file = ".runner"
capacity = 2
env_file = ".env"
timeout = "3h"
insecure = false
fetch_timeout = "5s"
fetch_interval = "2s"
labels = var.forgejo_runner_labels
}
cache = {
enabled = true
dir = ""
host = ""
port = 0
external_server = ""
}
container = {
network = null
privileged = false
options = null
workdir_parent = null
valid_volumes = []
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."
}
variable "forgejo_actions_runner_version" {
default = "latest"
default = "6"
type = string
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" {
description = "The number of instances of the runner to run"
type = number
@ -52,6 +60,7 @@ variable "service_name" {
variable "stack_name" {
type = string
description = "The name of the stack to deploy the service to."
default = "forgejo"
}
variable "placement_constraints" {
default = []

View file

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

View file

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

View file

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

View file

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