variable "nextcloud_db" { type = string default = "nextcloud" } variable "nextcloud_user" { type = string default = "nextcloud" } variable "nextcloud_pass" { type = string default = "nextcloud" } variable "backup_config" { type = string description = "HCL config for Restic Scheduler jobs" } job "nextcloud" { datacenters = ["dc1"] type = "service" group "nextcloud" { count = 1 network { mode = "bridge" port "web" { host_network = "loopback" to = 80 } port "backup" { to = 8080 } } volume "nextcloud-data" { type = "host" read_only = false source = "nextcloud-data" } service { name = "nextcloud" port = "web" connect { sidecar_service { proxy { local_service_port = 80 upstreams { destination_name = "mysql-server" local_bind_port = 6060 } config { protocol = "tcp" } } } sidecar_task { resources { cpu = 50 memory = 50 } } } tags = [ "traefik.enable=true", "traefik.http.routers.nextcloud.entryPoints=websecure", ] } task "nextcloud-bootstrap" { driver = "docker" lifecycle { hook = "prestart" sidecar = false } config { image = "mysql:8" args = [ "/bin/bash", "-c", "/usr/bin/mysql -h${NOMAD_UPSTREAM_IP_mysql_server} -P${NOMAD_UPSTREAM_PORT_mysql_server} -uroot -psupersecretpassword < /bootstrap.sql", ] mount { type = "bind" source = "local/bootstrap.sql" target = "/bootstrap.sql" } } template { data = <