Moves gitea to its own module (with common traefik labels)

This commit is contained in:
Nemo 2018-02-07 00:47:37 +05:30
parent f0a21b08b0
commit b4345810f5
15 changed files with 108 additions and 100 deletions

View File

@ -26,11 +26,6 @@ data "docker_registry_image" "traefik" {
name = "traefik:cancoillotte-alpine"
}
# https://github.com/go-gitea/gitea/releases
data "docker_registry_image" "gitea" {
name = "gitea/gitea:1.4"
}
data "docker_registry_image" "airsonic" {
name = "linuxserver/airsonic:latest"
}

View File

@ -1,78 +0,0 @@
resource docker_container "gitea" {
name = "gitea"
image = "${docker_image.gitea.latest}"
labels {
"traefik.port" = 3000
"traefik.enable" = "true"
"traefik.frontend.rule" = "Host:git.captnemo.in"
"traefik.frontend.headers.STSSeconds" = "2592000"
"traefik.frontend.headers.browserXSSFilter" = "true"
"traefik.frontend.headers.contentTypeNosniff" = "true"
"traefik.frontend.headers.SSLTemporaryRedirect" = "true"
"traefik.frontend.headers.STSIncludeSubdomains" = "false"
"traefik.frontend.headers.customResponseHeaders" = "${var.xpoweredby}"
}
ports {
internal = 22
external = 2222
ip = "${var.ips["eth0"]}"
}
ports {
internal = 22
external = 2222
ip = "${var.ips["tun0"]}"
}
volumes {
volume_name = "${docker_volume.gitea_volume.name}"
container_path = "/data"
host_path = "${docker_volume.gitea_volume.mountpoint}"
}
# Logos
# TODO: Add svg
upload {
content = "${file("${path.module}/conf/gitea/public/img/gitea-lg.png")}"
file = "/data/gitea/public/img/gitea-lg.png"
}
upload {
content = "${file("${path.module}/conf/gitea/public/img/gitea-sm.png")}"
file = "/data/gitea/public/img/gitea-sm.png"
}
upload {
content = "${file("${path.module}/conf/gitea/public/img/gitea-sm.png")}"
file = "/data/gitea/public/img/favicon.png"
}
upload {
content = "${file("${path.module}/conf/humans.txt")}"
file = "/data/gitea/public/humans.txt"
}
# Extra Links in header
upload {
content = "${file("${path.module}/conf/gitea/extra_links.tmpl")}"
file = "/data/gitea/templates/custom/extra_links.tmpl"
}
# This is the main configuration file
upload {
content = "${data.template_file.gitea-config-file.rendered}"
file = "/data/gitea/conf/app.ini"
}
memory = 256
restart = "unless-stopped"
destroy_grace_seconds = 10
must_run = true
}
data "template_file" "gitea-config-file" {
template = "${file("${path.module}/conf/gitea/conf.ini.tpl")}"
vars {
secret_key = "${var.gitea-secret-key}"
internal_token = "${var.gitea-internal-token}"
smtp_password = "${var.gitea-smtp-password}"
}
}

View File

@ -23,11 +23,6 @@ resource "docker_image" "traefik" {
pull_triggers = ["${data.docker_registry_image.traefik.sha256_digest}"]
}
resource "docker_image" "gitea" {
name = "${data.docker_registry_image.gitea.name}"
pull_triggers = ["${data.docker_registry_image.gitea.sha256_digest}"]
}
resource "docker_image" "airsonic" {
name = "${data.docker_registry_image.airsonic.name}"
pull_triggers = ["${data.docker_registry_image.airsonic.sha256_digest}"]

View File

@ -53,7 +53,3 @@ variable "domain" {
variable "ips" {
type = "map"
}
variable "gitea-secret-key" {}
variable "gitea-internal-token" {}
variable "gitea-smtp-password" {}

View File

@ -2,10 +2,6 @@ resource "docker_volume" "mariadb_volume" {
name = "mariadb_volume"
}
resource "docker_volume" "gitea_volume" {
name = "gitea_volume"
}
resource "docker_volume" "mongorocks_data_volume" {
name = "mongorocks_data_volume"
}

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

14
gitea/data.tf Normal file
View File

@ -0,0 +1,14 @@
# https://github.com/go-gitea/gitea/releases
data "docker_registry_image" "gitea" {
name = "gitea/gitea:1.4"
}
data "template_file" "gitea-config-file" {
template = "${file("${path.module}/conf/conf.ini.tpl")}"
vars {
secret_key = "${var.secret-key}"
internal_token = "${var.internal-token}"
smtp_password = "${var.smtp-password}"
}
}

67
gitea/main.tf Normal file
View File

@ -0,0 +1,67 @@
resource docker_container "gitea" {
name = "gitea"
image = "${docker_image.gitea.latest}"
labels = "${merge(
var.traefik-labels, map(
"traefik.port", 3000,
"traefik.frontend.rule","Host:${var.domain}"
))}"
ports {
internal = 22
external = 2222
ip = "${var.ips["eth0"]}"
}
ports {
internal = 22
external = 2222
ip = "${var.ips["tun0"]}"
}
volumes {
volume_name = "${docker_volume.gitea_volume.name}"
container_path = "/data"
host_path = "${docker_volume.gitea_volume.mountpoint}"
}
# Logos
# TODO: Add svg
upload {
content = "${file("${path.module}/conf/public/img/gitea-lg.png")}"
file = "/data/gitea/public/img/gitea-lg.png"
}
upload {
content = "${file("${path.module}/conf/public/img/gitea-sm.png")}"
file = "/data/gitea/public/img/gitea-sm.png"
}
upload {
content = "${file("${path.module}/conf/public/img/gitea-sm.png")}"
file = "/data/gitea/public/img/favicon.png"
}
upload {
content = "${file("${path.module}/../docker/conf/humans.txt")}"
file = "/data/gitea/public/humans.txt"
}
# Extra Links in header
upload {
content = "${file("${path.module}/conf/extra_links.tmpl")}"
file = "/data/gitea/templates/custom/extra_links.tmpl"
}
# This is the main configuration file
upload {
content = "${data.template_file.gitea-config-file.rendered}"
file = "/data/gitea/conf/app.ini"
}
memory = 256
restart = "unless-stopped"
destroy_grace_seconds = 10
must_run = true
}
resource "docker_image" "gitea" {
name = "${data.docker_registry_image.gitea.name}"
pull_triggers = ["${data.docker_registry_image.gitea.sha256_digest}"]
}

13
gitea/variables.tf Normal file
View File

@ -0,0 +1,13 @@
variable "traefik-labels" {
type = "map"
}
variable "domain" {}
variable "ips" {
type = "map"
}
variable "secret-key" {}
variable "internal-token" {}
variable "smtp-password" {}

3
gitea/volume.tf Normal file
View File

@ -0,0 +1,3 @@
resource "docker_volume" "gitea_volume" {
name = "gitea_volume"
}

15
main.tf
View File

@ -23,9 +23,16 @@ module "docker" {
wiki_session_secret = "${var.wiki_session_secret}"
ips = "${var.ips}"
domain = "bb8.fun"
gitea-secret-key = "${var.gitea-secret-key}"
gitea-internal-token = "${var.gitea-internal-token}"
gitea-smtp-password = "${var.gitea-smtp-password}"
}
module "gitea" {
source = "gitea"
domain = "git.captnemo.in"
traefik-labels = "${var.traefik-common-labels}"
ips = "${var.ips}"
secret-key = "${var.gitea-secret-key}"
internal-token = "${var.gitea-internal-token}"
smtp-password = "${var.gitea-smtp-password}"
}
module "radicale" {
@ -47,7 +54,7 @@ module "media" {
domain = "bb8.fun"
links-emby = "${module.docker.names-emby}"
links-transmission = "${module.docker.names-transmission}"
traefik-labels = "${var.traefik-common-labels}"
traefik-labels = "${var.traefik-common-labels}"
}
module "monitoring" {