diff --git a/jupyter.tf b/jupyter.tf index 3deceed..05dc6bf 100644 --- a/jupyter.tf +++ b/jupyter.tf @@ -1,12 +1,16 @@ -# module "jupyter" { -# name = "jupyter" -# source = "modules/container" -# image = "jupyter/tensorflow-notebook" -# ports = [ -# { -# internal = 8888 -# external = 1112 -# ip = "${var.ips["tun0"]}" -# }, -# ] -# } +module "jupyter" { + name = "jupyter" + source = "./modules/container" + image = "jupyter/scipy-notebook" + resource = { + memory = 1024 + memory_swap = 4096 + } + web = { + expose = "true" + host = "j.${var.root-domain}" + port = 8888 + } + networks = ["bridge"] + gpu = true +} diff --git a/modules/container/main.tf b/modules/container/main.tf index 19c7c93..aa4c4ad 100644 --- a/modules/container/main.tf +++ b/modules/container/main.tf @@ -19,6 +19,8 @@ resource "docker_container" "container" { network_mode = var.network_mode + gpus = var.gpu ? "all" : "" + dynamic "capabilities" { for_each = [var.capabilities] content { diff --git a/modules/container/providers.tf b/modules/container/providers.tf index c8e3cc2..ed370db 100644 --- a/modules/container/providers.tf +++ b/modules/container/providers.tf @@ -1,9 +1,7 @@ terraform { - experiments = [module_variable_optional_attrs] required_providers { docker = { source = "kreuzwerker/docker" - version = "2.15.0" } } } diff --git a/modules/container/vars.tf b/modules/container/vars.tf index 82c0239..978ad29 100644 --- a/modules/container/vars.tf +++ b/modules/container/vars.tf @@ -135,3 +135,8 @@ variable "uploads" { default = [] } + +variable "gpu" { + type = bool + default = false +} diff --git a/providers.tf b/providers.tf index baa3523..65488cf 100644 --- a/providers.tf +++ b/providers.tf @@ -31,6 +31,7 @@ provider "pass" { terraform { + required_version = ">= 1.3.0" required_providers { pass = { source = "camptocamp/pass" @@ -46,6 +47,7 @@ terraform { } docker = { source = "kreuzwerker/docker" + version = "~> 2.23" } } }