From 6d369812212d3ec39691b4a2d0893dc0f0b3cdfc Mon Sep 17 00:00:00 2001 From: Alexander Richards Date: Mon, 9 Dec 2019 16:24:59 +0000 Subject: [PATCH] Updating for CentOS8. --- build/Dockerfile | 33 ++++++++++++++++++--------------- build/build.sh | 6 ++++-- build/startup.sh | 46 +++++++++++++++++++++++++++++++++++++++------- 3 files changed, 61 insertions(+), 24 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 66b2b47..4231ed9 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,32 +1,35 @@ # syntax = docker/dockerfile:1.0-experimental -FROM centos:7 -ARG dirac_version=v6r21p7 +from centos:8 +ARG dirac_version=v6r22p6 ARG lcgtools_version=v14r1 ARG python_version=27 ARG productionsystem_version=master -RUN yum install -y centos-release-scl -RUN yum install -y rh-python36 -RUN yum install -y wget git gcc -RUN yum clean all +RUN dnf swap -y coreutils-single coreutils # Fix for wrapper coreutils +RUN dnf install -y gcc git wget python2 python3 python3-devel +RUN alternatives --set python /usr/bin/python2 # Set unversioned python command to python2 for DIRAC scripts +RUN python3 -m pip install --upgrade pip setuptools wheel +RUN python3 -m pip install --upgrade productionsystem@git+https://github.com/alexanderrichards/ProductionSystem.git@$productionsystem_version +RUN dnf clean all +# DIRAC setup RUN mkdir -p /root/dirac_ui - WORKDIR /root/dirac_ui - RUN wget -np -O dirac-install https://raw.githubusercontent.com/DIRACGrid/DIRAC/integration/Core/scripts/dirac-install.py RUN chmod u+x dirac-install -RUN ./dirac-install -r $dirac_version -i $python_version -g $lcgtools_version +RUN ./dirac-install --dirac-os -r $dirac_version -i $python_version -g $lcgtools_version RUN --mount=type=secret,id=proxy,dst=/tmp/x509up_u0 . /root/dirac_ui/bashrc && dirac-configure -F -S GridPP -C dips://dirac01.grid.hep.ph.ic.ac.uk:9135/Configuration/Server -I +# These two lines are necessary as git commands broken in DIRACOS so need to check out first then pip install else could do commented out line below +RUN git clone -b $productionsystem_version https://github.com/alexanderrichards/ProductionSystem.git +RUN . /root/dirac_ui/bashrc && python -m pip install --upgrade ProductionSystem/ +#RUN . /root/dirac_ui/bashrc && python -m pip install -v --trusted-host github.com --upgrade productionsystem@git+https://github.com/alexanderrichards/ProductionSystem.git@$productionsystem_version RUN rm -f dirac-install -WORKDIR /root -RUN echo "virtualenv venv3" | scl enable rh-python36 - -RUN . venv3/bin/activate && pip install --upgrade pip setuptools wheel -RUN --mount=type=ssh . venv3/bin/activate && pip install productionsystem@git+git://github.com/alexanderrichards/ProductionSystem.git@$productionsystem_version -RUN . dirac_ui/bashrc && python -m pip install --upgrade pip setuptools wheel -RUN --mount=type=ssh . dirac_ui/bashrc && python -m pip install --upgrade productionsystem@git+git://github.com/alexanderrichards/ProductionSystem.git@$productionsystem_version +## setup cron jobs - maybe not needed if mounting from outside. + + +WORKDIR /root COPY startup.sh /root/startup.sh diff --git a/build/build.sh b/build/build.sh index a94369a..7758e90 100755 --- a/build/build.sh +++ b/build/build.sh @@ -1,2 +1,4 @@ -#!/usr/bin/env bash -DOCKER_BUILDKIT=1 docker build --ssh default --no-cache --progress=plain --secret id=proxy,src=/tmp/x509up_u$ID -t alexanderrichards/productionsystem:latest . +#!/bin/bash +(. ~/dirac_ui/bashrc && dirac-proxy-init -x) +#DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain --secret id=proxy,src=/tmp/x509up_u`id -u` -t alexanderrichards/productionsystem:latest . +DOCKER_BUILDKIT=1 docker build --progress=plain --secret id=proxy,src=/tmp/x509up_u`id -u` -t alexanderrichards/productionsystem:latest . diff --git a/build/startup.sh b/build/startup.sh index 42d2cbe..1c51d7f 100755 --- a/build/startup.sh +++ b/build/startup.sh @@ -1,4 +1,32 @@ -#!/usr/bin/env bash +#!/bin/bash + +trap "stop_daemon $1 && exit 0" SIGTERM + +function stop_daemon { + case "$1" in + dirac) + echo "*** Stopping DIRAC daemon. ***" + (. /root/dirac_ui/bashrc && dirac-daemon.py stop) + ;; + monitoring) + echo "*** Stopping monitoring daemon. ***" + monitoring-daemon.py stop + ;; + webapp) + echo "*** Stopping web app daemon. ***" + webapp-daemon.py stop + ;; + all) + stop_daemon dirac + stop_daemon monitoring + stop_daemon webapp + ;; + *) + echo "Unknown parameter: $1" + echo "Expected: {dirac|monitoring|webapp|all}" + exit 1 + esac +} function start_daemon { case "$1" in @@ -8,16 +36,16 @@ function start_daemon { ;; monitoring) echo "*** Starting monitoring daemon. ***" - (. /root/venv3/bin/activate && monitoring-daemon.py start) + monitoring-daemon.py start ;; webapp) echo "*** Starting web app daemon. ***" - (. /root/venv3/bin/activate && webapp-daemon.py start) + webapp-daemon.py start ;; all) - start_daemon dirac - start_daemon monitoring - start_daemon webapp + start_daemon dirac + start_daemon monitoring + start_daemon webapp ;; *) echo "Unknown parameter: $1" @@ -27,4 +55,8 @@ function start_daemon { } start_daemon $1 -/bin/bash +# Allow time to receive and process SIGTERM handler +while true +do +sleep 5 +done