Skip to content

Commit 4312cd8

Browse files
committed
Added version 25.
Signed-off-by: Hermann Mayer <hermann.mayer92@gmail.com>
1 parent c9893e6 commit 4312cd8

10 files changed

Lines changed: 290 additions & 1 deletion

File tree

.github/workflows/package.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
matrix:
2121
version:
2222
- latest
23+
- 25
2324
- 24
2425
- 22
2526
steps:

25/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:25
2+
LABEL org.opencontainers.image.authors="containers@hausgold.de"
3+
4+
# You can change this environment variable on run's with -e
5+
ENV MDNS_HOSTNAME=node.local
6+
ENV NODE_OPTIONS="--max_old_space_size=8192"
7+
8+
# Install system packages
9+
RUN apt-get update -yqqq && \
10+
apt-get install -y \
11+
dbus avahi-daemon avahi-utils libnss-mdns haproxy supervisor
12+
13+
# Copy custom scripts
14+
COPY config/*.sh /usr/local/bin/
15+
RUN chmod +x /usr/local/bin/*
16+
17+
# Configure haproxy
18+
COPY config/haproxy.conf /etc/haproxy/haproxy.cfg
19+
20+
# Configure supervisord
21+
COPY config/supervisor/* /etc/supervisor/conf.d/
22+
RUN mkdir -p /var/log/supervisor
23+
24+
# Define the command to run per default
25+
CMD ["/usr/bin/supervisord", "-nc", "/etc/supervisor/supervisord.conf"]

25/Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
MAKEFLAGS += --warn-undefined-variables
2+
SHELL := bash
3+
.SHELLFLAGS := -eu -o pipefail -c
4+
.DEFAULT_GOAL := all
5+
.DELETE_ON_ERROR:
6+
.SUFFIXES:
7+
.PHONY:
8+
9+
# Environment switches
10+
REGISTRY ?=
11+
CANONICAL_NAME ?= node
12+
IMAGE_NAME ?= hausgold/$(CANONICAL_NAME)
13+
IMAGE_REF ?= 25
14+
IMAGE_URI := $(IMAGE_NAME):$(IMAGE_REF)
15+
16+
# Host binaries
17+
CURL ?= curl
18+
DOCKER ?= docker
19+
EXIT ?= exit
20+
GREP ?= grep
21+
SLEEP ?= sleep
22+
TEST ?= test
23+
TIME ?= time
24+
25+
# Define a retry helper
26+
define retry
27+
if eval "$(1)"; then exit 0; fi; \
28+
for i in 1; do sleep 10s; echo "Retrying $$i..."; \
29+
if eval "$(1)"; then exit 0; fi; \
30+
done; \
31+
exit 1
32+
endef
33+
34+
all:
35+
# mDNS enabled official/node
36+
#
37+
# build Build a development snapshot of the image
38+
# test Test the built Docker image
39+
# publish Push the new Docker image to the registry
40+
#
41+
# shell You can start an individual session of the image for tests
42+
# clean Clean the current development snapshot
43+
44+
build: clean
45+
# Build the Docker image
46+
@$(TIME) $(DOCKER) build --no-cache -t "$(IMAGE_URI)" .
47+
48+
test:
49+
# Test the built Docker image
50+
#
51+
# Not yet implemented.
52+
53+
publish:
54+
# Push the new Docker image to the registry
55+
@$(call retry,$(TIME) $(SHELL) -c '$(DOCKER) push $(IMAGE_URI)')
56+
57+
shell:
58+
# Start an individual test session of the image
59+
@$(DOCKER) run --rm -it "$(IMAGE_URI)" bash
60+
61+
clean:
62+
# Clean the current development snapshot
63+
@$(DOCKER) rmi --force "$(IMAGE_URI)" || true

25/config/avahi.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
NSS_MDNS=$(dpkg -s libnss-mdns | grep Version: \
4+
| cut -d: -f2 | cut -d- -f1 | tr -d ' ')
5+
6+
if [ "${NSS_MDNS}" != '0.10' ]; then
7+
# After nss-mdns >0.10 we need to reconfigure the allowed hosts to support
8+
# multiple sub-domain resolution
9+
cat > /etc/mdns.allow <<EOF
10+
.local.
11+
.local
12+
EOF
13+
14+
# And we need to make use of the +mdns+ nss module, not the minimal one so
15+
# that the above configuration will be used (see:
16+
# https://github.com/lathiat/nss-mdns)
17+
sed -i 's/mdns4_minimal/mdns4/' /etc/nsswitch.conf
18+
fi
19+
20+
# Configure the mDNS hostname on avahi
21+
if [ -n "${MDNS_HOSTNAME}" ]; then
22+
23+
# MDNS_HOSTNAME could be node.local or node.sub.local
24+
IFS='.' read -ra MDNS_HOSTNAME_PARTS <<< "${MDNS_HOSTNAME}"
25+
26+
# Save the first part as host part
27+
HOST_PART="${MDNS_HOSTNAME_PARTS[0]}"
28+
29+
# Shift the first part
30+
MDNS_HOSTNAME_PARTS=("${MDNS_HOSTNAME_PARTS[@]:1}")
31+
32+
# Join the rest to the domain part
33+
DOMAIN_PART=$(IFS='.'; echo "${MDNS_HOSTNAME_PARTS[*]}")
34+
35+
# Set the host and domain part on the avahi config
36+
sed \
37+
-e "s/.*\(host-name=\).*/\1${HOST_PART}/g" \
38+
-e "s/.*\(domain-name=\).*/\1${DOMAIN_PART}/g" \
39+
-e "s/.*\(enable-dbus=\).*/\1yes/g" \
40+
-i /etc/avahi/avahi-daemon.conf
41+
42+
echo "Configured mDNS hostname to ${MDNS_HOSTNAME}"
43+
fi
44+
45+
# Configure all mDNS CNAMEs on avahi
46+
if [ -n "${MDNS_CNAMES}" ]; then
47+
48+
# MDNS_CNAMES could be a single domain, or a comma-separated list
49+
IFS=',' read -ra CNAMES <<< "${MDNS_CNAMES}"
50+
51+
for CNAME in "${CNAMES[@]}"; do
52+
# Construct the command
53+
COMMAND='/usr/bin/avahi-publish -f -a -R'
54+
COMMAND+=" \"${CNAME}\" \`hostname -i\`"
55+
56+
# Write a new supervisord unit file
57+
cat > "/etc/supervisor/conf.d/${CNAME}.conf" <<EOF
58+
[program:${CNAME}]
59+
priority=20
60+
directory=/tmp
61+
command=/bin/sh -c '${COMMAND}'
62+
user=root
63+
autostart=false
64+
autorestart=true
65+
stopsignal=KILL
66+
stopwaitsecs=1
67+
EOF
68+
69+
# Reload the supervisord config files and start
70+
# the current publish service
71+
supervisorctl update
72+
supervisorctl start "${CNAME}"
73+
done
74+
fi
75+
76+
# Disable the rlimits from default debian
77+
sed \
78+
-e 's/^\(rlimit\)/#\1/g' \
79+
-i /etc/avahi/avahi-daemon.conf
80+
81+
# If a avahi daemon is running, kill it
82+
avahi-daemon -c && avahi-daemon -k
83+
84+
# Clean up orphans
85+
rm -rf /run/avahi-daemon/{pid,socket}
86+
87+
# Start avahi
88+
exec avahi-daemon --no-rlimits

25/config/dbus.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# dbus-daemon tries to reads passwd/group data, and on an non-systemd system,
4+
# where systemd is configured for NSS it causes a 90 second hang. So we drop
5+
# the systemd configuration for NSS.
6+
#
7+
# See: https://github.com/systemd/systemd/issues/16471#issuecomment-662377106
8+
sed -i 's/ systemd//g' /etc/nsswitch.conf
9+
10+
# Prepare the environment for dbus
11+
rm -rf /var/run/dbus /run/dbus
12+
mkdir -p /var/run/dbus/ /run/dbus
13+
chmod ugo+rwx /var/run/dbus/ /run/dbus
14+
15+
# systemd service activation makes no sense on a non-systemd system.
16+
# Looks like this is not needed currently/anymore.
17+
# cat >/etc/dbus-1/system.d/no-systemd.conf <<EOF
18+
# <!DOCTYPE busconfig PUBLIC
19+
# "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
20+
# "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
21+
# <busconfig>
22+
# <limit name="service_start_timeout">1</limit>
23+
# <servicehelper>/bin/true</servicehelper>
24+
# </busconfig>
25+
# EOF
26+
27+
# Start dbus
28+
exec /usr/bin/dbus-daemon --system --nofork

25/config/haproxy.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
global
2+
log /dev/log local0
3+
log /dev/log local1 notice
4+
chroot /var/lib/haproxy
5+
stats socket /run/haproxy/admin.sock mode 660 level admin
6+
stats timeout 30s
7+
user haproxy
8+
group haproxy
9+
# daemon
10+
11+
# Default SSL material locations
12+
ca-base /etc/ssl/certs
13+
crt-base /etc/ssl/private
14+
15+
# Default ciphers to use on SSL-enabled listening sockets.
16+
# For more information, see ciphers(1SSL). This list is from:
17+
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
18+
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
19+
ssl-default-bind-options no-sslv3
20+
21+
defaults
22+
log global
23+
mode http
24+
option httplog
25+
option dontlognull
26+
timeout connect 5000
27+
timeout client 300000
28+
timeout server 300000
29+
errorfile 400 /etc/haproxy/errors/400.http
30+
errorfile 403 /etc/haproxy/errors/403.http
31+
errorfile 408 /etc/haproxy/errors/408.http
32+
errorfile 500 /etc/haproxy/errors/500.http
33+
errorfile 502 /etc/haproxy/errors/502.http
34+
errorfile 503 /etc/haproxy/errors/503.http
35+
errorfile 504 /etc/haproxy/errors/504.http
36+
37+
frontend http-in
38+
bind *:80
39+
option forwardfor
40+
option http-server-close
41+
use_backend rest
42+
43+
backend rest
44+
server localhost 127.0.0.1:3000

25/config/supervisor/avahi.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[program:avahi]
2+
priority=10
3+
startretries=20
4+
directory=/tmp
5+
command=/usr/local/bin/avahi.sh
6+
user=root
7+
autostart=true
8+
autorestart=true
9+
stdout_logfile=/dev/stdout
10+
stdout_logfile_maxbytes=0
11+
stderr_logfile=/dev/stderr
12+
stderr_logfile_maxbytes=0
13+
stopsignal=KILL
14+
stopwaitsecs=1

25/config/supervisor/dbus.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[program:dbus]
2+
priority=0
3+
directory=/tmp
4+
command=/usr/local/bin/dbus.sh
5+
user=root
6+
autostart=true
7+
autorestart=true
8+
stdout_logfile=/dev/stdout
9+
stdout_logfile_maxbytes=0
10+
stderr_logfile=/dev/stderr
11+
stderr_logfile_maxbytes=0
12+
stopsignal=KILL
13+
stopwaitsecs=1

25/config/supervisor/haproxy.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[program:haproxy]
2+
priority=10
3+
directory=/tmp
4+
command=/bin/sh -c "mkdir -p /run/haproxy/ && exec /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg"
5+
user=root
6+
autostart=true
7+
autorestart=true
8+
# stdout_logfile=/dev/stdout
9+
# stdout_logfile_maxbytes=0
10+
# stderr_logfile=/dev/stderr
11+
# stderr_logfile_maxbytes=0
12+
stopsignal=KILL
13+
stopwaitsecs=1

latest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24
1+
25

0 commit comments

Comments
 (0)