From 3343ee20722cc5a0eb2826d5bbead505dc60c3e3 Mon Sep 17 00:00:00 2001
From: Hannes Feldt <feldt@astron.nl>
Date: Tue, 29 Oct 2024 09:23:31 +0100
Subject: [PATCH] Add consul to nomad container

---
 nomad/Dockerfile     | 7 +++++++
 nomad/files/nomad.sh | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/nomad/Dockerfile b/nomad/Dockerfile
index bce2c40..b379721 100644
--- a/nomad/Dockerfile
+++ b/nomad/Dockerfile
@@ -1,6 +1,7 @@
 FROM ghcr.io/jumppad-labs/dind:v1.1.2
 
 ARG NOMAD_VERSION
+ARG CONSUL_VERSION
 ARG TARGETARCH
 
 ENV CNI_PLUGINS=1.5.1
@@ -16,6 +17,12 @@ RUN curl -L https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_
   chmod +x /usr/bin/nomad && \
   rm /tmp/nomad.zip
 
+RUN curl -L https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_${TARGETARCH}.zip -o /tmp/consul.zip && \
+  cd /tmp && \
+  unzip consul.zip consul -d /usr/bin && \
+  chmod +x /usr/bin/consul && \
+  rm /tmp/consul.zip
+
 # Install the CNI Plugins
 RUN curl -L https://github.com/containernetworking/plugins/releases/download/v${CNI_PLUGINS}/cni-plugins-linux-${TARGETARCH}-v${CNI_PLUGINS}.tgz -o /tmp/cni.tgz && \
   mkdir -p /opt/cni/bin && \
diff --git a/nomad/files/nomad.sh b/nomad/files/nomad.sh
index 2a6c8ff..3024d50 100644
--- a/nomad/files/nomad.sh
+++ b/nomad/files/nomad.sh
@@ -13,6 +13,9 @@ fi
 # Start the docker daemon
 /usr/local/bin/dockerd.sh &
 
+# Start the consul agent
+/usr/bin/consul agent -config /etc/consul.d -log-level=DEBUG &
+
 # Start the nomad agent
 /usr/bin/nomad agent -config /etc/nomad.d -log-level=DEBUG &
 
-- 
GitLab