Skip to content

Commit

Permalink
Add nextcloud (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobroker authored Aug 14, 2021
1 parent 7e797e4 commit 63f8fb1
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 90 deletions.
22 changes: 0 additions & 22 deletions k8s/httpbin/deployment.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions k8s/httpbin/ingress.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions k8s/httpbin/manifest.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions k8s/httpbin/service.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions src/live/_local/storage-nextcloud/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/live/_local/storage-nextcloud/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
locals {
environment_vars = read_terragrunt_config(find_in_parent_folders("mounts.hcl"))
env = local.environment_vars.locals
}

terraform {
source = "../../..//modules/local-mount"
}

include {
path = find_in_parent_folders()
}

inputs = {
name = "mount-nextcloud"
mountpoint = local.env.nextcloud_path
}
7 changes: 7 additions & 0 deletions src/live/env.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
locals {
domain = "hobroker.me"

storage = {
appdata_path = "/appdata"
storage_path = "/storage"
Expand Down Expand Up @@ -75,4 +77,9 @@ locals {
code-server = {
port = 8001
}

nextcloud = {
port = 8004
config_path = "/appdata/nextcloud"
}
}
4 changes: 4 additions & 0 deletions src/live/grafana/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
locals {
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
domain = local.environment_vars.locals.domain
env = local.environment_vars.locals.grafana
}

Expand All @@ -12,13 +13,16 @@ include {
}

inputs = merge(local.env, {
tag = "8.1.1"
plugins = join(",", [
"grafana-strava-datasource",
"grafana-worldmap-panel",
"grafana-piechart-panel",
"grafana-googlesheets-datasource"
])
env = {
GF_SERVER_ROOT_URL = "https://${local.domain}.hobroker.me",
GF_STRAVA_DS_DATA_PATH = "/var/lib/grafana/strava"
}
})
ß
1 change: 1 addition & 0 deletions src/live/mounts.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
locals {
torrents_path = "/storage/downloads/torrents"
downloads_path = "/storage/downloads"
nextcloud_path = "/storage/nextcloud"
appdata_path = "/appdata"
compose_path = "/home/kira/compose"
storage_path = "/storage"
Expand Down
22 changes: 22 additions & 0 deletions src/live/nextcloud/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/live/nextcloud/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
locals {
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
env = local.environment_vars.locals.nextcloud
}

terraform {
source = "../..//modules/nextcloud"
}

include {
path = find_in_parent_folders()
}

dependency "storage_nextcloud" {
config_path = "../_local/storage-nextcloud"

mock_outputs_allowed_terraform_commands = ["validate", "plan"]
mock_outputs = {
volume = "mock-nextcloud-storage"
}
}

inputs = merge(local.env, {
data_volume = dependency.storage_nextcloud.outputs.volume
})
75 changes: 75 additions & 0 deletions src/modules/nextcloud/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
locals {
port = 443

ports = {
(var.port) = local.port
}
mounts = {
(docker_volume.config_volume.name) = "/config",
(var.data_volume) = "/data",
}
}

data "docker_registry_image" "image" {
name = "linuxserver/nextcloud:${var.tag}"
}

resource "docker_image" "image" {
name = data.docker_registry_image.image.name
pull_triggers = [data.docker_registry_image.image.sha256_digest]
}

resource "docker_volume" "config_volume" {
name = "${var.name}-config"
driver = "local-persist"
driver_opts = {
mountpoint = var.config_path
}
}

resource "docker_service" "app" {
name = var.name

task_spec {
// restart_policy = var.restart_policy

networks = var.network_ids

container_spec {
image = docker_image.image.name
env = {}

dynamic "mounts" {
for_each = local.mounts

content {
source = mounts.key
target = mounts.value
type = "volume"
}
}
}

placement {
constraints = [
"node.role==manager"
]
}

log_driver {
name = "json-file"
}
}

endpoint_spec {
dynamic "ports" {
for_each = local.ports

content {
target_port = ports.value
published_port = ports.key
protocol = "tcp"
}
}
}
}
3 changes: 3 additions & 0 deletions src/modules/nextcloud/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "port" {
value = var.port
}
48 changes: 48 additions & 0 deletions src/modules/nextcloud/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
variable "name" {
type = string
default = "nextcloud"
description = "Service name"
}

variable "tag" {
type = string
default = "latest"
description = "Image version tag"
}

variable "port" {
type = number
description = "WEBUI Port"
}

variable "network_ids" {
type = list(string)
default = []
description = "Service networks"
}

variable "restart_policy" {
type = object({
condition = string
delay = string
window = string
max_attempts = number
})
default = {
condition = "on-failure"
delay = "3s"
window = "10s"
max_attempts = 3
}
description = "Restart policy"
}

variable "config_path" {
type = string
description = "config folder path"
}

variable "data_volume" {
type = string
description = "data volume name"
}

0 comments on commit 63f8fb1

Please sign in to comment.