Skip to content

Commit 9b55d90

Browse files
authored
Support v1.10.x (#299)
1 parent d62e3b7 commit 9b55d90

File tree

7 files changed

+194
-0
lines changed

7 files changed

+194
-0
lines changed

.github/renovate.json5

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
{
7575
"matchFileNames": ["v1.9.x/**"],
7676
"matchPackageNames": ["hashicorp/nomad"],
77+
"allowedVersions": "<=1.9",
78+
"groupName": "nomad-1.9.x",
79+
},
80+
{
81+
"matchFileNames": ["v1.10.x/**"],
82+
"matchPackageNames": ["hashicorp/nomad"],
7783
"ignoreUnstable": false,
7884
"groupName": "nomad-latest",
7985
},

.github/workflows/v1.10.x-build.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "v1.10.x: build"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- v1.10.x/**
9+
10+
pull_request:
11+
branches:
12+
- master
13+
paths:
14+
- v1.10.x/**
15+
16+
jobs:
17+
test:
18+
name: Test
19+
uses: ./.github/workflows/template-build.yml
20+
with:
21+
platforms: linux/amd64,linux/arm64
22+
directory: v1.10.x
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "v1.10.x: create tag"
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
paths:
9+
- v1.10.x/nomad-version
10+
11+
jobs:
12+
tag:
13+
name: Tag
14+
permissions:
15+
contents: write
16+
uses: ./.github/workflows/template-create-tag.yml
17+
secrets: inherit
18+
with:
19+
directory: v1.10.x

.github/workflows/v1.10.x-release.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "v1.10.x: release"
2+
3+
on:
4+
push:
5+
tags:
6+
- 1.9.**
7+
8+
jobs:
9+
release:
10+
name: Release
11+
permissions:
12+
contents: write
13+
packages: write
14+
discussions: write
15+
uses: ./.github/workflows/template-release.yml
16+
secrets: inherit
17+
with:
18+
platforms: linux/amd64,linux/arm64
19+
directory: v1.10.x

v1.10.x/Dockerfile

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM debian:12.9-slim
2+
3+
# Fetch the target information injected by Docker build
4+
ARG TARGETOS
5+
ARG TARGETARCH
6+
7+
SHELL ["/bin/bash", "-x", "-c", "-o", "pipefail"]
8+
9+
# https://releases.hashicorp.com/nomad/
10+
ARG NOMAD_VERSION
11+
RUN test -n "$NOMAD_VERSION" || (echo "NOMAD_VERSION argument must be set" && false)
12+
13+
RUN groupadd nomad \
14+
&& useradd --system --gid nomad nomad \
15+
&& mkdir --parents /nomad/data \
16+
&& mkdir --parents /etc/nomad \
17+
&& chown --recursive nomad:nomad /nomad /etc/nomad
18+
19+
# Allow to fetch artifacts from TLS endpoint during the builds and by Nomad after.
20+
# Install timezone data so we can run Nomad periodic jobs containing timezone information
21+
RUN apt-get update \
22+
&& apt-get install --yes --no-install-recommends \
23+
ca-certificates \
24+
dumb-init \
25+
libcap2 \
26+
tzdata \
27+
&& update-ca-certificates \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
31+
nomad_${NOMAD_VERSION}_${TARGETOS}_${TARGETARCH}.zip
32+
ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS \
33+
nomad_${NOMAD_VERSION}_SHA256SUMS
34+
ADD https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS.sig \
35+
nomad_${NOMAD_VERSION}_SHA256SUMS.sig
36+
37+
RUN apt-get update \
38+
&& apt-get install --yes --no-install-recommends \
39+
gnupg \
40+
unzip \
41+
&& GNUPGHOME="$(mktemp -d)" \
42+
&& export GNUPGHOME \
43+
&& gpg --keyserver pgp.mit.edu --keyserver keys.openpgp.org --keyserver keyserver.ubuntu.com --recv-keys "C874 011F 0AB4 0511 0D02 1055 3436 5D94 72D7 468F" \
44+
&& gpg --batch --verify nomad_${NOMAD_VERSION}_SHA256SUMS.sig nomad_${NOMAD_VERSION}_SHA256SUMS \
45+
&& grep nomad_${NOMAD_VERSION}_${TARGETOS}_${TARGETARCH}.zip nomad_${NOMAD_VERSION}_SHA256SUMS | sha256sum -c \
46+
&& unzip -d /bin nomad_${NOMAD_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
47+
&& chmod +x /bin/nomad \
48+
&& rm -rf "$GNUPGHOME" nomad_${NOMAD_VERSION}_${TARGETOS}_${TARGETARCH}.zip nomad_${NOMAD_VERSION}_SHA256SUMS nomad_${NOMAD_VERSION}_SHA256SUMS.sig \
49+
&& apt-get autoremove --purge --yes \
50+
gnupg \
51+
unzip \
52+
&& rm -rf /var/lib/apt/lists/*
53+
54+
RUN nomad version
55+
56+
EXPOSE 4646 4647 4648 4648/udp
57+
58+
COPY start.sh /usr/local/bin/
59+
60+
ENTRYPOINT ["/usr/local/bin/start.sh"]

v1.10.x/nomad-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.10.0-beta.1

v1.10.x/start.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/dumb-init /bin/sh
2+
# shellcheck shell=dash
3+
# Script created following Hashicorp's model for Consul:
4+
# https://github.com/hashicorp/docker-consul/blob/master/0.X/docker-entrypoint.sh
5+
# Comments in this file originate from the project above, simply replacing 'Consul' with 'Nomad'.
6+
set -e
7+
8+
# Note above that we run dumb-init as PID 1 in order to reap zombie processes
9+
# as well as forward signals to all processes in its session. Normally, sh
10+
# wouldn't do either of these functions so we'd leak zombies as well as do
11+
# unclean termination of all our sub-processes.
12+
# As of docker 1.13, using docker run --init achieves the same outcome.
13+
14+
# NOMAD_DATA_DIR is exposed as a volume for possible persistent storage. The
15+
# NOMAD_CONFIG_DIR isn't exposed as a volume but you can compose additional
16+
# config files in there if you use this image as a base, or use NOMAD_LOCAL_CONFIG
17+
# below.
18+
NOMAD_DATA_DIR=${NOMAD_DATA_DIR:-"/nomad/data"}
19+
NOMAD_CONFIG_DIR=${NOMAD_CONFIG_DIR:-"/etc/nomad"}
20+
21+
# You can also set the NOMAD_LOCAL_CONFIG environemnt variable to pass some
22+
# Nomad configuration JSON without having to bind any volumes.
23+
if [ -n "$NOMAD_LOCAL_CONFIG" ]; then
24+
echo "$NOMAD_LOCAL_CONFIG" > "$NOMAD_CONFIG_DIR/local.json"
25+
fi
26+
27+
# If the user is trying to run Nomad directly with some arguments, then
28+
# pass them to Nomad.
29+
if [ "$(printf "%s" "$1" | cut -c 1)" = '-' ]; then
30+
set -- nomad "$@"
31+
fi
32+
33+
# Look for Nomad subcommands.
34+
if [ "$1" = 'agent' ]; then
35+
shift
36+
set -- nomad agent \
37+
-data-dir="$NOMAD_DATA_DIR" \
38+
-config="$NOMAD_CONFIG_DIR" \
39+
"$@"
40+
elif [ "$1" = 'version' ]; then
41+
# This needs a special case because there's no help output.
42+
set -- nomad "$@"
43+
elif nomad --help "$1" 2>&1 | grep -q "nomad $1"; then
44+
# We can't use the return code to check for the existence of a subcommand, so
45+
# we have to use grep to look for a pattern in the help output.
46+
set -- nomad "$@"
47+
fi
48+
49+
# If we are running Nomad, make sure it executes as the proper user.
50+
if [ "$1" = 'nomad' ] && [ -z "${NOMAD_DISABLE_PERM_MGMT+x}" ]; then
51+
# If the data or config dirs are bind mounted then chown them.
52+
# Note: This checks for root ownership as that's the most common case.
53+
if [ "$(stat -c %u "$NOMAD_DATA_DIR")" != "$(id -u root)" ]; then
54+
chown root:root "$NOMAD_DATA_DIR"
55+
fi
56+
57+
# If requested, set the capability to bind to privileged ports before
58+
# we drop to the non-root user. Note that this doesn't work with all
59+
# storage drivers (it won't work with AUFS).
60+
if [ -n "${NOMAD+x}" ]; then
61+
setcap "cap_net_bind_service=+ep" /bin/nomad
62+
fi
63+
64+
exec runuser -u root -- "$@"
65+
fi
66+
67+
exec "$@"

0 commit comments

Comments
 (0)