This commit is contained in:
fix 2021-03-10 16:26:32 +01:00
parent 1ee095d1af
commit 2ec0e4a09d
4 changed files with 43 additions and 11 deletions

View File

@ -63,16 +63,16 @@ FROM alpine:3
ENV UID=1000 ENV UID=1000
ENV GID=1000 ENV GID=1000
RUN \
apk update --no-cache && \
apk add --no-cache --virtual \
openssl \
zlib \
lua5.3-libs \
pcre2
COPY --from=builder /haproxy/haproxy /haproxy COPY --from=builder /haproxy/haproxy /haproxy
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT \ ENTRYPOINT /docker-entrypoint.sh
(\
grep -qE '^haproxy:x:'"${UID}"':haproxy$' /etc/group || addgroup -g "${GID}" haproxy\
) && \
(\
grep -qE '^haproxy:x:'"${UID}"':'"${GID}"':.*$' /etc/passwd || adduser -D -u "${UID}" -G haproxy haproxy \
) && \
chmod 700 /etc/haproxy && chown haproxy:haproxy /etc/haproxy
CMD su haproxy -c "/haproxy -f /haproxy"

View File

@ -13,6 +13,10 @@ services:
tag: haproxy tag: haproxy
restart: unless-stopped restart: unless-stopped
ports: ports:
- 8443:8443 - ${EXTERNAL_IP}:${PORT_PLAIN}:80
- ${EXTERNAL_IP}:${PORT_TLS}:443
- ${STATS_IP}:${PORT_STATS}:8404
volumes: volumes:
- ${HAPROXY_CONFIG_FILE_PATH}:/etc/haproxy/haproxy.cfg:ro - ${HAPROXY_CONFIG_FILE_PATH}:/etc/haproxy/haproxy.cfg:ro
- ${HAPROXY_CERTS_PATH}:/etc/ssl/certs:ro

22
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/ash
set -e
if ! grep -qE '^haproxy:x:'"${UID}"':haproxy$' /etc/group ; then
addgroup -g "${GID}" haproxy
fi
if ! grep -qE '^haproxy:x:'"${UID}"':'"${GID}"':.*$' /etc/passwd ; then
adduser -D -u "${UID}" -G haproxy haproxy
fi
mkdir -vp \
/etc/haproxy \
/var/run/haproxy
chmod 700 /etc/haproxy
chown haproxy:haproxy \
/etc/haproxy \
/var/run/haproxy
su haproxy -c '/haproxy -f /etc/haproxy/haproxy.cfg'

View File

@ -1,3 +1,9 @@
EXTERNAL_IP=127.0.0.1
HAPROXY_REPO='https://scm.f1x.online/mirrors/haproxy.git' HAPROXY_REPO='https://scm.f1x.online/mirrors/haproxy.git'
HAPROXY_VERSION= HAPROXY_VERSION=
HAPROXY_CONFIG_FILE_PATH=/path/to/haproxy.conf HAPROXY_CONFIG_FILE_PATH=/path/to/haproxy.conf
HAPROXY_CERTS_PATH=/path/to/certs
PORT_STATS=8404
PORT_PLAIN=80
PORT_TLS=443
STATS_IP=127.0.0.1