Parcourir la source

Modify healthcheck, remove sed and awk from entrypoint

Vadim Surkov il y a 6 ans
Parent
commit
67632ac899
3 fichiers modifiés avec 21 ajouts et 10 suppressions
  1. 3 2
      Dockerfile
  2. 8 8
      docker-entrypoint.sh
  3. 10 0
      healthcheck.sh

+ 3 - 2
Dockerfile

@@ -1,6 +1,6 @@
 FROM registry.sdsys.ru/iru/iru-base:0.1
 ENTRYPOINT ["docker-entrypoint.sh"]
-COPY docker-entrypoint.sh /opt/tomcat8/bin/docker-entrypoint.sh
+COPY docker-entrypoint.sh healthcheck.sh /opt/tomcat8/bin/
 ENV CATALINA_HOME="/opt/tomcat8" 
 ENV PATH=$CATALINA_HOME/bin:$PATH \
     CATALINA_OPTS="-Dconfig.file=/etc/web-infoclinic/application.conf" \
@@ -9,7 +9,7 @@ ENV PATH=$CATALINA_HOME/bin:$PATH \
     WORKDIR=$CATALINA_HOME \
     DB_CLUSTER=mongodb
 EXPOSE 8080 8009 2551
-HEALTHCHECK --start-period=300s --interval=15s --timeout=5s --retries=2 CMD curl -f 127.0.0.1:8080/login || exit 1
+HEALTHCHECK --start-period=300s --interval=15s --timeout=5s --retries=2 CMD healthcheck.sh
 ARG repo=prod
 RUN set -x \
            && curl https://repo.infoclinica.ru/yum/centos/sds-${repo}-portal.repo -o /etc/yum.repos.d/sds-${repo}-portal.repo \
@@ -17,6 +17,7 @@ RUN set -x \
            && yum install web-registry-admin -y \
            && yum clean all \
            && chmod +x /opt/tomcat8/bin/docker-entrypoint.sh \
+           && chmod +x /opt/tomcat8/bin/healthcheck.sh \
            && chown -R tomcat:tomcat /etc/web-infoclinic
 USER tomcat
 CMD ["catalina.sh", "run"]

+ 8 - 8
docker-entrypoint.sh

@@ -1,13 +1,13 @@
 #!/usr/bin/env bash
 
-if [ "$DB_CLUSTER" ]; then
-   sed -i 's/"dev-mongo\.infoclinica\.lan:27017"/\$\{DB_CLUSTER\}/' /etc/web-infoclinic/application.conf
-   sed -i 's/"mongo41\.infoclinica\.lan:27017,mongo42\.infoclinica\.lan:27017,mongo43\.infoclinica\.lan:27017"/\$\{DB_CLUSTER\}/' /etc/web-infoclinic/application.conf
+if [ ! -z "${APPNET}" ]; then
+   echo "Initial nslookup ${HOSTNAME}.${APPNET}"
+   nslookup ${HOSTNAME}.${APPNET}
+   while [ $? -ne 0 ]; do
+     echo "Waiting for ${HOSTNAME}.${APPNET} to become available"
+     sleep 1
+     nslookup ${HOSTNAME}.${APPNET}
+   done
 fi
 
-sed -i "s/192\.168\.201\.11/0\.0\.0\.0/" /etc/web-infoclinic/application.conf
-sed -i "s/192\.168\.204\.12/0\.0\.0\.0/" /etc/web-infoclinic/application.conf
-
-sed -i "s/communication = \"remote\"/communication = \"socket\"/" /etc/web-infoclinic/application.conf
-
 exec "$@"

+ 10 - 0
healthcheck.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+containerstart=`stat -c %Z /proc/1`
+curtime=`date +%s`
+if [[ $(($containerstart-$curtime)) -le "180" ]]; then
+    echo "0"
+    exit 0
+fi
+
+curl -f 127.0.0.1:8080/login || exit 1