From 0081f4de711722b0d9cb991bcab14fd7cb3dfbb6 Mon Sep 17 00:00:00 2001 From: manojks1999 <64463831+manojks1999@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:17:18 +0530 Subject: [PATCH] Chore: Fixed Docker Health Check (#2659) * docker_healthcheck_fix * grep_fix_for_alpine * added environment variable for healthcheck and changed the port extraction accorfingly --- tools/docker/healthcheck.sh | 6 +++++- tools/packaging/Dockerfile.alpine-dev | 2 +- tools/packaging/Dockerfile.ubuntu-dev | 2 +- tools/packaging/Dockerfile.ubuntu-prod | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/docker/healthcheck.sh b/tools/docker/healthcheck.sh index a8dae4e86..96899299e 100755 --- a/tools/docker/healthcheck.sh +++ b/tools/docker/healthcheck.sh @@ -1,7 +1,11 @@ #!/bin/sh HOST="localhost" -PORT=6379 +PORT=$HEALTHCHECK_PORT + +if [ -z "$HEALTHCHECK_PORT" ]; then + PORT=$(netstat -tuln | grep -oE ':[0-9]+' | grep -oE '[0-9]+' | tail -n 1) +fi # If we're running with TLS enabled, utilise OpenSSL for the check if [ -f "/etc/dragonfly/tls/ca.crt" ] diff --git a/tools/packaging/Dockerfile.alpine-dev b/tools/packaging/Dockerfile.alpine-dev index 183c4c54c..252d9a7ae 100644 --- a/tools/packaging/Dockerfile.alpine-dev +++ b/tools/packaging/Dockerfile.alpine-dev @@ -4,7 +4,7 @@ FROM gcr.io/cadvisor/cadvisor:v0.46.0 as libpfm_donor FROM alpine:3 as builder # "openssl-libs-static" fixes "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the" -RUN apk add autoconf-archive automake bash bison boost-dev cmake coreutils \ +RUN apk add autoconf-archive automake bash bison boost-dev cmake coreutils net-tools \ curl ccache git gcc gdb g++ libunwind-dev libtool make ninja \ openssl-dev openssl-libs-static patch zip zstd-static diff --git a/tools/packaging/Dockerfile.ubuntu-dev b/tools/packaging/Dockerfile.ubuntu-dev index d6512139b..2046ee3d2 100644 --- a/tools/packaging/Dockerfile.ubuntu-dev +++ b/tools/packaging/Dockerfile.ubuntu-dev @@ -17,7 +17,7 @@ FROM ubuntu:20.04 RUN --mount=type=tmpfs,target=/var/cache/apt \ --mount=type=tmpfs,target=/var/lib/apt/lists \ apt update && \ - apt install -q -y --no-install-recommends netcat-openbsd ca-certificates redis-tools + apt install -q -y --no-install-recommends netcat-openbsd ca-certificates redis-tools net-tools RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly RUN mkdir /data && chown dfly:dfly /data diff --git a/tools/packaging/Dockerfile.ubuntu-prod b/tools/packaging/Dockerfile.ubuntu-prod index 67c312d15..c8c06d5fb 100644 --- a/tools/packaging/Dockerfile.ubuntu-prod +++ b/tools/packaging/Dockerfile.ubuntu-prod @@ -25,7 +25,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN --mount=type=tmpfs,target=/var/cache/apt \ --mount=type=tmpfs,target=/var/lib/apt/lists \ apt -q update && \ - apt install -q -y --no-install-recommends netcat-openbsd ca-certificates redis-tools + apt install -q -y --no-install-recommends netcat-openbsd ca-certificates redis-tools net-tools RUN groupadd -r -g 999 dfly && useradd -r -g dfly -u 999 dfly RUN mkdir /data && chown dfly:dfly /data