Changes for OPML-gen deployment

This commit is contained in:
Nemo 2018-06-01 02:25:49 +05:30
parent c3c5c7d0bc
commit b9965f2092
7 changed files with 78 additions and 0 deletions

View File

@ -53,6 +53,14 @@ module "gitea" {
mysql-password = "${var.gitea-mysql-password}"
}
module "opml" {
source = "opml"
domain = "opml.bb8.fun"
client-id = "${var.opml-github-client-id}"
client-secret = "${var.opml-github-client-secret}"
traefik-labels = "${var.traefik-common-labels}"
}
module "radicale" {
source = "radicale"
domain = "radicale.bb8.fun"

7
opml/data.tf Normal file
View File

@ -0,0 +1,7 @@
data "docker_registry_image" "opml" {
name = "captn3m0/opml-gen:latest"
}
data "docker_registry_image" "redis" {
name = "redis:alpine"
}

28
opml/main.tf Normal file
View File

@ -0,0 +1,28 @@
resource "docker_container" "opml" {
name = "opml"
image = "${docker_image.opml.latest}"
labels = "${merge(
var.traefik-labels, map(
"traefik.port", 80,
"traefik.frontend.rule","Host:${var.domain}"
))}"
env = [
"GITHUB_CLIENT_ID=${var.client-id}",
"GITHUB_CLIENT_SECRET=${var.client-secret}",
"REDIS_URL=redis://opml-redis:6379/1",
]
memory = 256
restart = "unless-stopped"
destroy_grace_seconds = 10
must_run = true
networks = ["${docker_network.opml.id}"]
}
resource "docker_image" "opml" {
name = "${data.docker_registry_image.opml.name}"
pull_triggers = ["${data.docker_registry_image.opml.sha256_digest}"]
}

4
opml/network.tf Normal file
View File

@ -0,0 +1,4 @@
resource "docker_network" "opml" {
name = "opml"
driver = "bridge"
}

21
opml/redis.tf Normal file
View File

@ -0,0 +1,21 @@
resource "docker_container" "redis" {
name = "opml-redis"
image = "${docker_image.redis.latest}"
volumes {
host_path = "/mnt/xwing/cache/opml-redis"
container_path = "/data"
}
memory = 256
restart = "unless-stopped"
destroy_grace_seconds = 10
must_run = true
networks = ["${docker_network.opml.id}"]
}
resource "docker_image" "redis" {
name = "${data.docker_registry_image.redis.name}"
pull_triggers = ["${data.docker_registry_image.redis.sha256_digest}"]
}

7
opml/variables.tf Normal file
View File

@ -0,0 +1,7 @@
variable "traefik-labels" {
type = "map"
}
variable "domain" {}
variable "client-id" {}
variable "client-secret" {}

View File

@ -72,3 +72,6 @@ variable "traefik-common-labels" {
variable "timemachine-password-2" {}
variable "timemachine-password-1" {}
variable "opml-github-client-id" {}
variable "opml-github-client-secret" {}