Browse Source

kaarana.org wordpress website

kaarana-wordpress
Nemo 1 year ago
parent
commit
d4370f2b56
9 changed files with 156 additions and 10 deletions
  1. +20
    -0
      kaarana.tf
  2. +40
    -0
      kaarana/database.tf
  3. +26
    -0
      kaarana/images.tf
  4. +11
    -0
      kaarana/traefik.tf
  5. +8
    -0
      kaarana/vars.tf
  6. +34
    -0
      kaarana/wordpress.tf
  7. +8
    -9
      kayak.tf
  8. +8
    -1
      providers.tf
  9. +1
    -0
      server.tf

+ 20
- 0
kaarana.tf View File

@ -0,0 +1,20 @@
# kaarana related stuff
module "kaarana" {
source = "./kaarana"
root_db_password = "${data.pass_password.kaarana-root-db-password.password}"
db_password = "${data.pass_password.kaarana-db-password.password}"
providers = {
docker = "docker.sydney"
}
}
data "pass_password" "kaarana-root-db-password" {
path = "KAARANA_DB_ROOT_PASSWORD"
}
data "pass_password" "kaarana-db-password" {
path = "KAARANA_DB_PASSWORD"
}

+ 40
- 0
kaarana/database.tf View File

@ -0,0 +1,40 @@
// Create a small database network
resource "docker_network" "kaarana-db" {
name = "kaarana-db"
labels = {
internal = "true"
role = "database"
}
internal = true
ipam_config {
subnet = "172.20.0.0/29"
gateway = "172.20.0.1"
}
}
// Run a small mySQL container in this subnet
resource "docker_container" "mysql" {
image = "${docker_image.db.latest}"
name = "kaarana-mariadb"
env = [
"MYSQL_ROOT_PASSWORD=${var.root_db_password}",
"MYSQL_USER=${local.username}",
"MYSQL_PASSWORD=${var.db_password}",
"MYSQL_DATABASE=${local.database}",
]
volumes {
host_path = "/mnt/disk/kaarana-db"
container_path = "/var/lib/mysql"
}
networks_advanced {
name = "kaarana-db"
aliases = ["${local.db_hostname}"]
}
}

+ 26
- 0
kaarana/images.tf View File

@ -0,0 +1,26 @@
data "docker_registry_image" "wp" {
name = "wordpress:latest"
}
resource "docker_image" "wp" {
name = "wordpress"
pull_triggers = ["${data.docker_registry_image.wp.sha256_digest}"]
}
data "docker_registry_image" "db" {
name = "mariadb:10.4"
}
resource "docker_image" "db" {
name = "mariadb"
pull_triggers = ["${data.docker_registry_image.db.sha256_digest}"]
}
data "docker_registry_image" "traefik" {
name = "traefik:v2.0"
}
resource "docker_image" "traefik" {
name = "traefik"
pull_triggers = ["${data.docker_registry_image.db.sha256_digest}"]
}

+ 11
- 0
kaarana/traefik.tf View File

@ -0,0 +1,11 @@
// Create a small database network
resource "docker_network" "traefik" {
name = "traefik"
labels = {
internal = "true"
role = "ingress"
}
internal = true
}

+ 8
- 0
kaarana/vars.tf View File

@ -0,0 +1,8 @@
variable "root_db_password" {}
variable "db_password" {}
locals {
username = "wordpress"
database = "wordpress"
db_hostname = "kaarana.db"
}

+ 34
- 0
kaarana/wordpress.tf View File

@ -0,0 +1,34 @@
resource "docker_container" "wp" {
image = "${docker_image.wp.latest}"
name = "kaarana-wordpress"
env = [
"WORDPRESS_DB_HOST=${local.db_hostname}",
"WORDPRESS_DB_USER=${local.username}",
"WORDPRESS_DB_PASSWORD=${var.db_password}",
"WORDPRESS_DB_NAME=${local.database}",
"WORDPRESS_TABLE_PREFIX=",
]
volumes {
host_path = "/mnt/disk/kaarana-wp"
container_path = "/var/www/html"
}
ports {
internal = 8080
external = 8213
ip = "10.8.0.1"
}
networks_advanced = [
{
name = "kaarana-db"
},
{
// TODO: Once configuration/plugins have stabilized
// remove internet access from wordpress
name = "bridge"
},
]
}

+ 8
- 9
kayak.tf View File

@ -10,15 +10,14 @@
# docker = "docker.kayak"
# }
# }
provider "docker" {
host = "tcp://${cloudflare_record.kayak-docker.hostname}:2376"
version = "~> 2.0.0"
alias = "kayak"
ca_material = "${module.kayak.docker_ca_cert}"
cert_material = "${module.kayak.docker_client_cert}"
key_material = "${module.kayak.docker_client_key}"
}
# provider "docker" {
# host = "tcp://${cloudflare_record.kayak-docker.hostname}:2376"
# version = "~> 2.0.0"
# alias = "kayak"
# ca_material = "${module.kayak.docker_ca_cert}"
# cert_material = "${module.kayak.docker_client_cert}"
# key_material = "${module.kayak.docker_client_key}"
# }
# resource "cloudflare_record" "kayak-docker" {
# name = "docker.kayak"
# value = "${module.kayak.droplet_ipv4}"


+ 8
- 1
providers.tf View File

@ -1,7 +1,14 @@
provider "docker" {
host = "tcp://docker.vpn.bb8.fun:2376"
cert_path = "./secrets/tatooine"
version = "~> 2.0.0"
version = "~> 2.2.0"
}
provider "docker" {
host = "tcp://docker.dovpn.bb8.fun:2376"
cert_path = "./secrets/sydney"
version = "~> 2.2.0"
alias = "sydney"
}
provider "kubernetes" {


+ 1
- 0
server.tf View File

@ -0,0 +1 @@

Loading…
Cancel
Save