Browse Source

feat: add more services

pull/3/head
Karan Sharma 1 year ago
parent
commit
fbe359d263
  1. 35
      floyd/terraform/bookstack/container.tf
  2. 17
      floyd/terraform/bookstack/image.tf
  3. 28
      floyd/terraform/bookstack/mariadb.tf
  4. 5
      floyd/terraform/bookstack/network.tf
  5. 7
      floyd/terraform/bookstack/variables.tf
  6. 8
      floyd/terraform/bookstack/versions.tf
  7. 32
      floyd/terraform/gitea/container.tf
  8. 8
      floyd/terraform/gitea/image.tf
  9. 3
      floyd/terraform/gitea/variables.tf
  10. 8
      floyd/terraform/gitea/versions.tf
  11. 11
      floyd/terraform/main.tf
  12. 7
      floyd/terraform/variables.tf

35
floyd/terraform/bookstack/container.tf

@ -0,0 +1,35 @@
# Referred to https://github.com/linuxserver/docker-bookstack
# for config.
resource "docker_container" "bookstack" {
name = "bookstack"
image = docker_image.bookstack.latest
volumes {
host_path = "/data/bookstack"
container_path = "/config"
}
ports {
internal = 80
external = 6875
ip = var.ips["tailscale_floyd"]
protocol = "tcp"
}
networks_advanced {
name = docker_network.bookstack.name
}
env = [
"PUID=1000",
"PGID=1000",
"DB_HOST=bookstack_db",
"DB_USER=bookstack",
"DB_PASS=${var.bookstack_mariadb_password}",
"DB_DATABASE=bookstackapp"
]
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
}

17
floyd/terraform/bookstack/image.tf

@ -0,0 +1,17 @@
data "docker_registry_image" "bookstack" {
name = "linuxserver/bookstack:latest"
}
resource "docker_image" "bookstack" {
name = data.docker_registry_image.bookstack.name
pull_triggers = [data.docker_registry_image.bookstack.sha256_digest]
}
data "docker_registry_image" "mariadb" {
name = "linuxserver/mariadb:latest"
}
resource "docker_image" "mariadb" {
name = data.docker_registry_image.mariadb.name
pull_triggers = [data.docker_registry_image.mariadb.sha256_digest]
}

28
floyd/terraform/bookstack/mariadb.tf

@ -0,0 +1,28 @@
# Referred to https://github.com/linuxserver/docker-bookstack
# for config.
resource "docker_container" "bookstack_db" {
name = "bookstack_db"
image = docker_image.mariadb.latest
volumes {
host_path = "/data/bookstack"
container_path = "/config"
}
env = [
"TZ=Asia/Kolkata",
"MYSQL_DATABASE=bookstackapp",
"MYSQL_USER=bookstack",
"MYSQL_PASSWORD=${var.bookstack_mariadb_password}",
"PUID=1000",
"PGID=1000"
]
networks_advanced {
name = docker_network.bookstack.name
}
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
}

5
floyd/terraform/bookstack/network.tf

@ -0,0 +1,5 @@
resource "docker_network" "bookstack" {
name = "bookstack"
driver = "bridge"
internal = "false"
}

7
floyd/terraform/bookstack/variables.tf

@ -0,0 +1,7 @@
variable "ips" {
type = map
}
variable "bookstack_mariadb_password" {
type = string
}

8
floyd/terraform/bookstack/versions.tf

@ -0,0 +1,8 @@
terraform {
required_providers {
docker = {
source = "terraform-providers/docker"
}
}
required_version = ">= 0.13"
}

32
floyd/terraform/gitea/container.tf

@ -0,0 +1,32 @@
# Referred to https://github.com/pi-hole/docker-pi-hole#quick-start
# for config.
resource "docker_container" "gitea" {
name = "gitea"
image = docker_image.gitea.latest
volumes {
host_path = "/data/gitea/"
container_path = "/data/"
}
# https://tools.ietf.org/html/rfc5966
# mentions to support TCP for DNS.
ports {
internal = 3000
external = 4000
ip = var.ips["tailscale_floyd"]
protocol = "tcp"
}
# DNS on UDP
ports {
internal = 22
external = 4222
ip = var.ips["tailscale_floyd"]
protocol = "tcp"
}
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
}

8
floyd/terraform/gitea/image.tf

@ -0,0 +1,8 @@
data "docker_registry_image" "gitea" {
name = "gitea/gitea:1.12.3"
}
resource "docker_image" "gitea" {
name = data.docker_registry_image.gitea.name
pull_triggers = [data.docker_registry_image.gitea.sha256_digest]
}

3
floyd/terraform/gitea/variables.tf

@ -0,0 +1,3 @@
variable "ips" {
type = map
}

8
floyd/terraform/gitea/versions.tf

@ -0,0 +1,8 @@
terraform {
required_providers {
docker = {
source = "terraform-providers/docker"
}
}
required_version = ">= 0.13"
}

11
floyd/terraform/main.tf

@ -11,3 +11,14 @@ module "unbound" {
source = "./unbound"
ips = var.ips
}
module "gitea" {
source = "./gitea"
ips = var.ips
}
module "bookstack" {
source = "./bookstack"
ips = var.ips
bookstack_mariadb_password = var.bookstack_mariadb_password
}

7
floyd/terraform/variables.tf

@ -3,6 +3,11 @@ variable "ips" {
default = {
tailscale_floyd = "100.101.134.59"
eth1 = "10.139.120.134"
eth1 = "10.139.120.134"
}
}
variable "bookstack_mariadb_password" {
type = string
description = "Password for Bookstack MariaDB server"
}

Loading…
Cancel
Save