File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed
Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -30,4 +30,8 @@ ENV ALLOW_RESTARTS=0 \
3030 TASKS=0 \
3131 VERSION=1 \
3232 VOLUMES=0
33- COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
33+ RUN apk add --no-cache gettext
34+ COPY docker-entrypoint.sh /
35+ COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg.template
36+
37+ ENTRYPOINT ["/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ # Normalize the input for ENABLE_IPV6 to lowercase
5+ ENABLE_IPV6_LOWER=$( echo " $ENABLE_IPV6 " | tr ' [:upper:]' ' [:lower:]' )
6+
7+ # Check for different representations of 'true' and set BIND_CONFIG
8+ case " $ENABLE_IPV6_LOWER " in
9+ 1|true|yes)
10+ BIND_CONFIG=" [::]:2375 v4v6"
11+ ;;
12+ * )
13+ BIND_CONFIG=" :2375"
14+ ;;
15+ esac
16+
17+ # Export BIND_CONFIG for envsubst
18+ export BIND_CONFIG
19+
20+ # Process the HAProxy configuration template
21+ envsubst < /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
22+ cat /usr/local/etc/haproxy/haproxy.cfg
23+
24+ # Command-line argument handling
25+ if [ " ${1# -} " != " $1 " ]; then
26+ set -- haproxy " $@ "
27+ fi
28+
29+ if [ " $# " -eq 0 ] || [ " $1 " = ' haproxy' ]; then
30+ if [ " $1 " = ' haproxy' ]; then
31+ shift
32+ fi
33+ set -- haproxy -W -db -f /usr/local/etc/haproxy/haproxy.cfg " $@ "
34+ fi
35+
36+ exec " $@ "
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ backend docker-events
4444 timeout server 0
4545
4646frontend dockerfrontend
47- bind :: :2375 v4v6
47+ bind ${BIND_CONFIG}
4848 http-request deny unless METH_GET || { env(POST) -m bool }
4949 http-request allow if { path,url_dec -m reg -i ^(/v[\ d\ .]+)?/containers/[a-zA-Z0-9_.-]+/((stop)|(restart)|(kill)) } { env(ALLOW_RESTARTS) -m bool }
5050 http-request allow if { path,url_dec -m reg -i ^(/v[\ d\ .]+)?/containers/[a-zA-Z0-9_.-]+/start } { env(ALLOW_START) -m bool }
You can’t perform that action at this time.
0 commit comments