Browse Source

feat: Add firefly

pull/3/head
Karan Sharma 1 year ago
parent
commit
dee84d7a67
  1. 11
      floyd/terraform/caddy/conf/Caddyfile.tpl
  2. 41
      floyd/terraform/firefly/container.tf
  3. 17
      floyd/terraform/firefly/image.tf
  4. 5
      floyd/terraform/firefly/network.tf
  5. 25
      floyd/terraform/firefly/postgres.tf
  6. 11
      floyd/terraform/firefly/variables.tf
  7. 8
      floyd/terraform/firefly/versions.tf
  8. 11
      floyd/terraform/main.tf
  9. 6
      floyd/terraform/monitoring/nodeexporter.tf
  10. 2
      floyd/terraform/monitoring/prometheus.tf
  11. 10
      floyd/terraform/variables.tf

11
floyd/terraform/caddy/conf/Caddyfile.tpl

@ -25,3 +25,14 @@ grafana.mrkaran.dev {
dns cloudflare "${cloudflare_api_token}"
}
}
firefly.mrkaran.dev {
reverse_proxy firefly:8080
tls {
dns cloudflare "${cloudflare_api_token}"
}
header {
# https://docs.firefly-iii.org/installation/docker#docker-and-reverse-proxies
X-Forwarded-Proto https
}
}

41
floyd/terraform/firefly/container.tf

@ -0,0 +1,41 @@
# Referred to https://docs.firefly-iii.org/installation/docker
# for config.
resource "docker_container" "firefly" {
name = "firefly"
image = docker_image.firefly.latest
volumes {
host_path = "/data/firefly/export"
container_path = "/var/www/firefly-iii/storage/export"
}
volumes {
host_path = "/data/firefly/upload"
container_path = "/var/www/firefly-iii/storage/upload"
}
networks_advanced {
name = docker_network.firefly.name
}
networks_advanced {
name = "caddy"
}
env = [
"DB_CONNECTION=pgsql",
"DB_HOST=firefly_db",
"DB_USERNAME=firefly",
"DB_PORT=5432",
"DB_PASSWORD=${var.firefly_postgres_password}",
"DB_DATABASE=firefly",
"TZ=Asia/Kolkata",
"APP_URL=https://firefly.mrkaran.dev",
"TRUSTED_PROXIES=**",
"APP_KEY=${var.firefly_app_key}",
]
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
}

17
floyd/terraform/firefly/image.tf

@ -0,0 +1,17 @@
data "docker_registry_image" "firefly" {
name = "jc5x/firefly-iii:stable"
}
resource "docker_image" "firefly" {
name = data.docker_registry_image.firefly.name
pull_triggers = [data.docker_registry_image.firefly.sha256_digest]
}
data "docker_registry_image" "postgres" {
name = "postgres:12"
}
resource "docker_image" "postgres" {
name = data.docker_registry_image.postgres.name
pull_triggers = [data.docker_registry_image.postgres.sha256_digest]
}

5
floyd/terraform/firefly/network.tf

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

25
floyd/terraform/firefly/postgres.tf

@ -0,0 +1,25 @@
# Referred to https://docs.firefly-iii.org/faq/self_hosted#i-want-to-use-postgresql
# for config.
resource "docker_container" "firefly_db" {
name = "firefly_db"
image = docker_image.postgres.latest
volumes {
host_path = "/data/firefly/db"
container_path = "/var/lib/postgres"
}
env = [
"POSTGRES_DB=firefly",
"POSTGRES_USER=firefly",
"POSTGRES_PASSWORD=${var.firefly_postgres_password}",
]
networks_advanced {
name = docker_network.firefly.name
}
restart = "unless-stopped"
destroy_grace_seconds = 30
must_run = true
}

11
floyd/terraform/firefly/variables.tf

@ -0,0 +1,11 @@
variable "ips" {
type = map
}
variable "firefly_postgres_password" {
type = string
}
variable "firefly_app_key" {
type = string
}

8
floyd/terraform/firefly/versions.tf

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

11
floyd/terraform/main.tf

@ -30,6 +30,13 @@ module "caddy" {
}
module "monitoring" {
source = "./monitoring"
ips = var.ips
source = "./monitoring"
ips = var.ips
}
module "firefly" {
source = "./firefly"
ips = var.ips
firefly_postgres_password = var.firefly_postgres_password
firefly_app_key = var.firefly_app_key
}

6
floyd/terraform/monitoring/nodeexporter.tf

@ -14,19 +14,19 @@ resource "docker_container" "nodeexporter" {
volumes {
host_path = "/proc"
container_path = "/host/proc"
read_only = true
read_only = true
}
volumes {
host_path = "/sys"
container_path = "/host/sys"
read_only = true
read_only = true
}
volumes {
host_path = "/"
container_path = "/rootfs"
read_only = true
read_only = true
}
networks_advanced {

2
floyd/terraform/monitoring/prometheus.tf

@ -24,7 +24,7 @@ resource "docker_container" "prometheus" {
}
upload {
content = "${file("${path.module}/conf/prometheus.yml")}"
content = file("${path.module}/conf/prometheus.yml")
file = "/etc/prometheus/prometheus.yml"
}

10
floyd/terraform/variables.tf

@ -16,3 +16,13 @@ variable "cloudflare_api_token" {
type = string
description = "API key to edit DNS zones in Cloudflare"
}
variable "firefly_postgres_password" {
type = string
description = "Password for Firefly PostgreSQL server"
}
variable "firefly_app_key" {
type = string
description = "32Char token uniquely generated to encrypt Firefly Sessions and Attachments"
}

Loading…
Cancel
Save