Add shlink to Terraform

This commit is contained in:
Layla 2024-06-03 19:39:30 +02:00
parent ac1a77cf85
commit 4e8919c1f4
6 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,8 @@
version: "3"
includes:
tf:
vars:
SERVICE: "shlink"
ENVIRONMENT: "main"
taskfile: ../../taskfiles/Taskfile_service.dist.yml

View File

@ -0,0 +1,28 @@
data "vault_generic_secret" "geolite" {
path = "secret/services/shlink/geolite"
}
resource "docker_container" "shlink" {
image = "shlinkio/shlink:${var.shlink_version}"
name = var.container_name
restart = "always"
env = [
"IS_HTTPS_ENABLED=false",
"DEFAULT_DOMAIN=lnk.layla.gg",
"GEOLITE_LICENSE_KEY=${data.vault_generic_secret.geolite.data["license_key"]}",
]
ports {
internal = 8080
external = 8602
}
mounts {
target = "/etc/shlink/data"
source = "/volume1/cloud/${var.container_name}/data"
read_only = false
type = "bind"
}
}

View File

@ -0,0 +1,10 @@
variable "shlink_version" {
description = "Container tag"
type = string
default = "1"
}
variable "container_name" {
description = "Container name"
type = string
}

View File

@ -0,0 +1,7 @@
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
}
}
}

View File

@ -0,0 +1,6 @@
module "shlink" {
source = "../_common"
container_name = "shlink"
shlink_version = "latest"
}

View File

@ -0,0 +1,7 @@
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
}
}
}