From b73499c5eec009fccea842323857f842b5402fe9 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 26 Apr 2024 13:36:04 +0200 Subject: [PATCH] Small cleanup --- .../ubnt-firmware-downloader/Dockerfile | 2 +- example/images/unifi/Dockerfile | 4 +- example/unifi.nomad.hcl | 43 ++++++++++++++++--- unifi.nomad.hcl | 13 +++--- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/example/images/ubnt-firmware-downloader/Dockerfile b/example/images/ubnt-firmware-downloader/Dockerfile index eca9484..ab6e9e2 100644 --- a/example/images/ubnt-firmware-downloader/Dockerfile +++ b/example/images/ubnt-firmware-downloader/Dockerfile @@ -1,4 +1,4 @@ -FROM danielberteaud/alpine:24.3-1 +FROM danielberteaud/alpine:24.4-1 MAINTAINER Daniel Berteaud ENV UBNT_UPDATE_API="https://fw-update.ubnt.com/api/firmware-latest?filter=eq~~product~~unifi-firmware&filter=eq~~channel~~release" \ diff --git a/example/images/unifi/Dockerfile b/example/images/unifi/Dockerfile index 105c3f1..7597192 100644 --- a/example/images/unifi/Dockerfile +++ b/example/images/unifi/Dockerfile @@ -1,4 +1,4 @@ -FROM danielberteaud/java:17.24.3-5 AS builder +FROM danielberteaud/java:17.24.4-1 AS builder ARG UNIFI_VERSION=8.1.113 @@ -12,7 +12,7 @@ RUN set -euxo pipefail &&\ rm -f UniFi/bin/mongod &&\ chown -R root:root UniFi -FROM danielberteaud/java:17.24.3-5 +FROM danielberteaud/java:17.24.4-1 MAINTAINER Daniel Berteaud ENV JAVA_OPTS="-Djava.awt.headless=true -Dlogback.configurationFile=/opt/unifi/logback.xml --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED" \ diff --git a/example/unifi.nomad.hcl b/example/unifi.nomad.hcl index 0e95271..30ac864 100644 --- a/example/unifi.nomad.hcl +++ b/example/unifi.nomad.hcl @@ -3,10 +3,18 @@ job "unifi" { region = "global" - - group "unifi" { + shutdown_delay = "6s" + + + + ephemeral_disk { + # Use minimal ephemeral disk + size = 101 + } + + network { mode = "bridge" port "stun" { @@ -18,6 +26,16 @@ job "unifi" { name = "unifi" port = 8888 + meta { + alloc = "${NOMAD_ALLOC_INDEX}" + datacenter = "${NOMAD_DC}" + group = "${NOMAD_GROUP_NAME}" + job = "${NOMAD_JOB_NAME}" + namespace = "${NOMAD_NAMESPACE}" + node = "${node.unique.name}" + region = "${NOMAD_REGION}" + } + connect { sidecar_service { } @@ -47,7 +65,7 @@ job "unifi" { type = "http" path = "/status" expose = true - interval = "10s" + interval = "30s" timeout = "5s" check_restart { limit = 12 @@ -98,6 +116,17 @@ job "unifi" { name = "unifi-mongo" port = 27017 + meta { + alloc = "${NOMAD_ALLOC_INDEX}" + datacenter = "${NOMAD_DC}" + group = "${NOMAD_GROUP_NAME}" + job = "${NOMAD_JOB_NAME}" + namespace = "${NOMAD_NAMESPACE}" + node = "${node.unique.name}" + region = "${NOMAD_REGION}" + } + + check { type = "script" command = "sh" @@ -114,6 +143,7 @@ job "unifi" { } + volume "mongo" { source = "unifi-mongo" type = "csi" @@ -123,6 +153,7 @@ job "unifi" { + volume "data" { source = "unifi-data" type = "csi" @@ -137,7 +168,7 @@ job "unifi" { user = 1053 config { - image = "danielberteaud/wait-for:24.3-1" + image = "danielberteaud/wait-for:24.4-1" readonly_rootfs = true pids_limit = 20 } @@ -290,8 +321,6 @@ _EOF env { - - TMPDIR = "/local/tmp" } @@ -390,7 +419,7 @@ _EOF } config { - image = "danielberteaud/mongo:5.0.24.3-1" + image = "danielberteaud/mongo:5.0.24.4-1" command = "mongod" readonly_rootfs = true pids_limit = 200 diff --git a/unifi.nomad.hcl b/unifi.nomad.hcl index 7012a64..5bc2ee6 100644 --- a/unifi.nomad.hcl +++ b/unifi.nomad.hcl @@ -5,6 +5,7 @@ job "[[ .instance ]]" { group "unifi" { [[- $c := merge .unifi.controller .unifi . ]] +[[ template "common/group_start" $c ]] network { mode = "bridge" @@ -17,14 +18,15 @@ job "[[ .instance ]]" { name = "[[ .instance ]][[ .consul.suffix ]]" port = 8888 +[[ template "common/service_meta" $c ]] [[ template "common/connect" $c ]] check { type = "http" path = "/status" expose = true - interval = "10s" - timeout = "5s" + interval = "[[ $c.consul.check.interval ]]" + timeout = "[[ $c.consul.check.timeout ]]" check_restart { limit = 12 grace = "2m" @@ -52,12 +54,14 @@ job "[[ .instance ]]" { name = "[[ .instance ]]-mongo[[ .consul.suffix ]]" port = 27017 +[[ template "common/service_meta" $c ]] + check { type = "script" command = "sh" args = ["-c", "mongo --quiet --eval 'db.runCommand(\"ping\").ok'"] - interval = "30s" - timeout = "5s" + interval = "[[ $c.consul.check.interval ]]" + timeout = "[[ $c.consul.check.timeout ]]" task = "mongo" check_restart { @@ -125,7 +129,6 @@ _EOF [[ template "common/vault.policies" $c ]] env { - [[ template "common/proxy_env" . ]] TMPDIR = "/local/tmp" }