Compare commits

...

3 Commits

  1. 8
      terraform/main.tf
  2. 8
      terraform/modules/caddy/conf/Caddyfile-public
  3. 13
      terraform/modules/cloudflare/records.tf
  4. 43
      terraform/modules/doggo/conf/doggo.nomad
  5. 7
      terraform/modules/doggo/job.tf

8
terraform/main.tf

@ -28,6 +28,14 @@ module "pihole" {
}
}
module "doggo" {
source = "./modules/doggo"
providers = {
nomad = nomad
}
}
module "shynet" {
source = "./modules/shynet"
shynet_postgresql_password = var.shynet_postgresql_password

8
terraform/modules/caddy/conf/Caddyfile-public

@ -16,3 +16,11 @@ git.mrkaran.dev {
}
}
doggo.mrkaran.dev {
{{ range service "doggo-web" }}
reverse_proxy {{ .Address }}:{{ .Port }}
{{ end }}
tls {
dns cloudflare "${cloudflare_api_token}"
}
}

13
terraform/modules/cloudflare/records.tf

@ -115,4 +115,17 @@ resource "cloudflare_record" "git" {
value = var.ips["floyd_public"]
}
resource "cloudflare_record" "doggo" {
zone_id = cloudflare_zone.mrkaran_dev.id
name = "doggo"
type = "A"
ttl = "1"
proxied = "true"
value = var.ips["floyd_public"]
}

43
terraform/modules/doggo/conf/doggo.nomad

@ -0,0 +1,43 @@
job "doggo" {
datacenters = ["hydra"]
type = "service"
group "app" {
count = 1
network {
port "http" {
to = 8080
}
}
restart {
attempts = 2
interval = "2m"
delay = "30s"
mode = "fail"
}
task "web" {
driver = "docker"
service {
name = "doggo-web"
tags = ["doggo", "web"]
port = "http"
}
config {
# TODO: use dockerhub for now, ghcr giving issues.
image = "mrkaran/doggo-api:v0.3.3"
ports = ["http"]
}
resources {
cpu = 200
memory = 200
}
}
}
}

7
terraform/modules/doggo/job.tf

@ -0,0 +1,7 @@
resource "nomad_job" "app" {
jobspec = templatefile("${path.module}/conf/doggo.nomad", {
})
hcl2 {
enabled = true
}
}
Loading…
Cancel
Save