Guest User

Nextcloud Nomad Job

a guest
Apr 6th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | Source Code | 0 0
  1. # Use a variable to control the nextcloud version between two containers
  2. job "nextcloud" {
  3. datacenters = ["dc1"]
  4. namespace = "dev"
  5. type = "service"
  6.  
  7. reschedule {
  8. delay = "30s"
  9. delay_function = "exponential"
  10. max_delay = "120s"
  11. unlimited = true
  12. }
  13.  
  14. group "nextcloud" {
  15. # Nextcloud takes time to initialze, so we give it a long healthy deadline
  16. update {
  17. min_healthy_time = "2m"
  18. healthy_deadline = "15m"
  19. progress_deadline = "20m"
  20. }
  21.  
  22. network {
  23. mode = "bridge"
  24. port "http" {
  25. to = 80
  26. }
  27. }
  28.  
  29. service {
  30. name = "nextcloud"
  31. port = "http"
  32. provider = "nomad"
  33. check {
  34. type = "http"
  35. path = "/"
  36. interval = "60s"
  37. timeout = "5s"
  38. }
  39. }
  40.  
  41. volume "nextcloud" {
  42. type = "csi"
  43. source = "nextcloud"
  44. attachment_mode = "file-system"
  45. access_mode = "multi-node-multi-writer"
  46. read_only = false
  47. }
  48.  
  49. volume "nextcloud-postgres" {
  50. type = "host"
  51. source = "nextcloud-postgres-dev"
  52. read_only = false
  53. }
  54.  
  55. task "nextcloud" {
  56. driver = "docker"
  57. config {
  58. image = "nextcloud:28.0.4"
  59. ports = ["http"]
  60. group_add = [105] # nextcloud recommends adding render group (which is 105 on host)
  61. devices = [
  62. {
  63. host_path = "/dev/dri"
  64. container_path = "/dev/dri"
  65. },
  66. ]
  67. }
  68. env {
  69. NEXTCLOUD_TRUSTED_DOMAINS = "nextcloud.domain.com 10.1.1.*"
  70. PHP_UPLOAD_LIMIT = "16G"
  71. TRUSTED_PROXIES = "172.26.64.0/20" # Nomad bridge network
  72. REDIS_HOST = "127.0.0.1"
  73. POSTGRES_HOST = "127.0.0.1"
  74. POSTGRES_DB = "nextcloud"
  75. # POSTGRES_USER = ""
  76. # POSTGRES_PASSWORD = ""
  77. }
  78. volume_mount {
  79. volume = "nextcloud"
  80. destination = "/var/www/html"
  81. }
  82. template {
  83. destination = "secrets/.env"
  84. env = true
  85. change_mode = "restart"
  86. data = <<-EOF
  87. {{- range nomadVarListSafe }}
  88. {{- if nomadVarExists .Path }}
  89. {{- with nomadVar .Path }}
  90. {{- range .Tuples }}
  91. {{ .K }}="{{ .V }}"
  92. {{- end }}
  93. {{- end }}
  94. {{- end }}
  95. {{- end }}
  96. EOF
  97. }
  98. resources {
  99. cpu = 500
  100. memory = 2048
  101. }
  102. }
  103.  
  104. task "cron" {
  105. driver = "docker"
  106. config {
  107. image = "nextcloud:28.0.4"
  108. entrypoint = ["/cron.sh"]
  109. group_add = [105]
  110. devices = [
  111. {
  112. host_path = "/dev/dri"
  113. container_path = "/dev/dri"
  114. },
  115. ]
  116. }
  117. env {
  118. NEXTCLOUD_TRUSTED_DOMAINS = "nextcloud.domain.com 10.1.1.*"
  119. PHP_UPLOAD_LIMIT = "16G"
  120. TRUSTED_PROXIES = "172.26.64.0/20" # Nomad bridge network
  121. REDIS_HOST = "127.0.0.1"
  122. POSTGRES_HOST = "127.0.0.1"
  123. POSTGRES_DB = "nextcloud"
  124. # POSTGRES_USER = ""
  125. # POSTGRES_PASSWORD = ""
  126. }
  127. volume_mount {
  128. volume = "nextcloud"
  129. destination = "/var/www/html"
  130. }
  131. template {
  132. destination = "secrets/.env"
  133. env = true
  134. change_mode = "restart"
  135. data = <<-EOF
  136. {{- range nomadVarListSafe }}
  137. {{- if nomadVarExists .Path }}
  138. {{- with nomadVar .Path }}
  139. {{- range .Tuples }}
  140. {{ .K }}="{{ .V }}"
  141. {{- end }}
  142. {{- end }}
  143. {{- end }}
  144. {{- end }}
  145. EOF
  146. }
  147. resources {
  148. cpu = 100
  149. memory = 128
  150. }
  151. }
  152.  
  153. task "redis" {
  154. driver = "docker"
  155. config {
  156. image = "redis:7-alpine"
  157. }
  158. resources {
  159. cpu = 250
  160. memory = 256
  161. }
  162. }
  163.  
  164. task "postgres" {
  165. driver = "docker"
  166. config {
  167. image = "postgres:16-alpine"
  168. }
  169. env {
  170. POSTGRES_DB = "nextcloud"
  171. # POSTGRES_USER = ""
  172. # POSTGRES_PASSWORD = ""
  173. }
  174. volume_mount {
  175. volume = "nextcloud-postgres"
  176. destination = "/var/lib/postgresql/data"
  177. }
  178. template {
  179. destination = "secrets/.env"
  180. env = true
  181. change_mode = "restart"
  182. data = <<-EOF
  183. {{- range nomadVarListSafe }}
  184. {{- if nomadVarExists .Path }}
  185. {{- with nomadVar .Path }}
  186. {{- range .Tuples }}
  187. {{ .K }}="{{ .V }}"
  188. {{- end }}
  189. {{- end }}
  190. {{- end }}
  191. {{- end }}
  192. EOF
  193. }
  194. resources {
  195. cpu = 250
  196. memory = 256
  197. }
  198. }
  199.  
  200. restart {
  201. attempts = 3
  202. delay = "2m"
  203. interval = "10m"
  204. mode = "delay"
  205. }
  206. }
  207. }
  208.  
Advertisement
Add Comment
Please, Sign In to add comment