diff --git a/docker/couchdb/Dockerfile b/docker/couchdb/Dockerfile index 6a1ac10d4..604096c37 100644 --- a/docker/couchdb/Dockerfile +++ b/docker/couchdb/Dockerfile @@ -1,8 +1,20 @@ -FROM couchdb:3.2.2 +FROM cmssw/filebeat:latest as filebeat +FROM couchdb:3.4.1 MAINTAINER Valentin Kuznetsov vkuznet@gmail.com -RUN apt-get update && apt-get install -y vim less sudo wget unzip python pip -RUN pip install CMSCouchapp +RUN apt-get update && apt-get install -y vim less sudo wget unzip python3 pip +# NOTE: +# RUN pip install CMSCouchapp +# when we install CMSCouchapp on Debian system it fails with PEP 668 error +# which prevents installing external (Python packages from pip) on Debian system +# there are two ways to resolve it: +# - option A: install with (potential) break of system packages +# RUN pip install --break-system-packages CMSCouchapp +# - option B: install in virtual environment +RUN apt install -y python3.11-venv +RUN python3 -m venv /data/venv +ENV PATH="/data/venv/bin:$PATH" +RUN pip install --no-cache-dir CMSCouchapp ENV WDIR=/data ENV USER=_couchdb @@ -24,9 +36,10 @@ RUN mkdir -p $WDIR WORKDIR ${WDIR} # get binary build of couchdb exporter -RUN curl -ksLO https://github.com/gesellix/couchdb-prometheus-exporter/releases/download/v27.0.0/couchdb-prometheus-exporter_27.0.0_Linux_x86_64.tar.gz -RUN tar xfz couchdb-prometheus-exporter_27.0.0_Linux_x86_64.tar.gz -RUN rm couchdb-prometheus-exporter_27.0.0_Linux_x86_64.tar.gz LICENSE README*.md +ARG VER=30.14.0 +RUN curl -ksLO https://github.com/gesellix/couchdb-prometheus-exporter/releases/download/v${VER}/couchdb-prometheus-exporter_${VER}_Linux_x86_64.tar.gz +RUN tar xfz couchdb-prometheus-exporter_${VER}_Linux_x86_64.tar.gz +RUN rm couchdb-prometheus-exporter_${VER}_Linux_x86_64.tar.gz LICENSE README*.md ENV PATH="${WDIR}:${PATH}" # add necessary scripts @@ -47,7 +60,12 @@ ADD manage /data/srv/current/config/couchdb/manage ENV PATH="/opt/couchdb/bin:/usr/local/bin/:${PATH}" +# copy exporters +COPY --from=filebeat /usr/share/filebeat /usr/share/filebeat +COPY --from=filebeat /usr/bin/filebeat /usr/bin/filebeat + # setup final environment USER $USER WORKDIR $WDIR +ENV PATH="/data/venv/bin:$PATH" CMD ["./run.sh"] diff --git a/docker/couchdb/manage b/docker/couchdb/manage index da7b4de16..469acd6ba 100755 --- a/docker/couchdb/manage +++ b/docker/couchdb/manage @@ -49,6 +49,9 @@ COLOR_OK="\\033[0;32m" COLOR_WARN="\\033[0;31m" COLOR_NORMAL="\\033[0;39m" PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/kerberos/bin:/usr/local/bin:/opt/couchdb/bin +if [ -f /data/venv/bin/couchapp ]; then + PATH=/data/venv/bin:$PATH +fi # Does the credential file exist and is it readable? if [ ! -r $COUCH_CREDS ]; then diff --git a/docker/couchdb/monitor.sh b/docker/couchdb/monitor.sh index ff638b4c7..f2e762a6d 100755 --- a/docker/couchdb/monitor.sh +++ b/docker/couchdb/monitor.sh @@ -2,13 +2,13 @@ # start couchdb exporter COUCH_CONFIG=/data/srv/current/auth/couchdb/couchdb_config.ini -export COUCHDB_NODE_NAME="couchdb@$(hostname)" # test if file is not zero size if [ -s "${COUCH_CONFIG}" ]; then - sudo cp /etc/secrets/$fname /data/srv/current/auth/$srv/$fname - sudo chown $USER.$USER /data/srv/current/auth/$srv/$fname - nohup couchdb-prometheus-exporter -telemetry.address=":9984" -logtostderr=true \ - --config=$COUCH_CONFIG -databases.views=false --databases=_all_dbs 2>&1 1>& couchdb_exporter.log < /dev/null & + #sudo cp /etc/secrets/$fname /data/srv/current/auth/$srv/$fname + #sudo chown $USER.$USER /data/srv/current/auth/$srv/$fname + echo "INFO: starting couchdb prometheus exporter with /data/couchdb_exporter.log" + nohup /data/couchdb-prometheus-exporter -telemetry.address=":9984" \ + --config=$COUCH_CONFIG -databases.views=false 2>&1 1>& /data/couchdb_exporter.log < /dev/null & else echo "ERROR: couchdb_config.ini file is empty and prometheus exporter cannot be started!" fi @@ -17,7 +17,10 @@ fi if [ -f /etc/secrets/filebeat.yaml ] && [ -f /usr/bin/filebeat ]; then ldir=/tmp/filebeat mkdir -p $ldir/data + echo "INFO: start filebeat with $ldir/log" nohup /usr/bin/filebeat \ -c /etc/secrets/filebeat.yaml \ --path.data $ldir/data --path.logs $ldir -e 2>&1 1>& $ldir/log < /dev/null & +else + echo "ERROR: filebeat process is not started as /etc/secrets/filebeat.yaml does not exist" fi diff --git a/docker/pypi/wmagent-couchdb/Dockerfile b/docker/pypi/wmagent-couchdb/Dockerfile index c4ad566bd..3fd7d5b56 100644 --- a/docker/pypi/wmagent-couchdb/Dockerfile +++ b/docker/pypi/wmagent-couchdb/Dockerfile @@ -6,7 +6,7 @@ ARG TAG ENV TAG=${TAG} RUN echo TAG=$TAG -RUN apt-get update && apt-get install -y vim less sudo wget unzip python pip +RUN apt-get update && apt-get install -y vim less sudo wget unzip python3 pip # # Install some debugging tools RUN apt-get install -y hostname net-tools iputils-ping procps emacs-nox tcpdump && apt-get clean @@ -14,7 +14,17 @@ RUN apt-get install -y hostname net-tools iputils-ping procps emacs-nox tcpdump # Install recursive ps utility tool RUN apt-get install -y pslist && apt-get clean -RUN pip install CMSCouchapp +# RUN pip install CMSCouchapp +# when we install CMSCouchapp on Debian system it fails with PEP 668 error +# which prevents installing external (Python packages from pip) on Debian system +# there are two ways to resolve it: +# - option A: install with (potential) break of system packages +# RUN pip install --break-system-packages CMSCouchapp +# - option B: install in virtual environment +RUN apt install -y python3.11-venv +RUN python3 -m venv /data/venv +ENV PATH="/data/venv/bin:$PATH" +RUN pip install --no-cache-dir CMSCouchapp ENV COUCH_PORT=5984 ENV COUCH_ROOT_DIR=/data