Skip to content

Commit e352af3

Browse files
committed
(socks-proxy) add healthcheck to dockerfile
1 parent 4d68cb4 commit e352af3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/socks-proxy/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG DANTE_SHA256=1973c7732f1f9f0a4c0ccf2c1ce462c7c25060b25643ea90f9b98f53a813fae
66

77
RUN <<EOR
88
apt-get update
9-
apt-get install -y build-essential curl
9+
DEBIAN_FRONTEND="noninteractive" apt-get install -y build-essential curl
1010
EOR
1111

1212
RUN <<EOR
@@ -22,9 +22,16 @@ EOR
2222

2323
FROM debian:trixie-slim AS runtime
2424

25-
COPY --from=base /usr/local/sbin/sockd /usr/local/sbin/sockd
25+
RUN <<EOR
26+
apt-get update
27+
DEBIAN_FRONTEND="noninteractive" apt-get install -y curl
28+
rm -rf /var/lib/apt/lists/*
29+
EOR
2630

31+
COPY --from=base /usr/local/sbin/sockd /usr/local/sbin/sockd
2732
COPY --chmod=0755 entrypoint.sh /entrypoint.sh
2833

2934
ENTRYPOINT ["/entrypoint.sh"]
35+
HEALTHCHECK --interval=1m --timeout=3s --start-interval=5s \
36+
CMD curl -fsSx socks5h://$(cat /healthcreds)@localhost:${PROXY_INTERNAL_PORT:-1080} https://ip.me
3037
CMD ["/usr/local/sbin/sockd"]

src/socks-proxy/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3+
umask 0077
34

45
if [ -z "${PROXY_USERS:-}" ]; then
56
echo "Error: PROXY_USERS env var is not set (format: user1:pass1,user2:pass2)"
67
exit 1
78
fi
89

10+
useradd -M -s /usr/sbin/nologin "healthcheck"
11+
HEALTHCHECK_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)
12+
echo "healthcheck:${HEALTHCHECK_PASSWORD}" | tee /healthcreds | chpasswd
13+
914
# Create unix users for each entry of PROXY_USERS
1015
IFS=',' read -ra USERS <<< "$PROXY_USERS"
1116
for entry in "${USERS[@]}"; do
@@ -59,6 +64,5 @@ done
5964

6065
# Replace the placeholder with the generated configuration
6166
echo "$DANTE_CONFIG" > /etc/sockd.conf
62-
chmod 0600 /etc/sockd.conf
6367

6468
exec "$@"

0 commit comments

Comments
 (0)