Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker image build files. #55

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ __pycache__/
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
Expand Down
25 changes: 25 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# syntax = docker/dockerfile:1.0-experimental
ARG dirac_version=v6r22p26
FROM alexanderrichards/dirac_ui:${dirac_version}
ARG productionsystem_version=master

RUN yum install -y git gcc cronie python3 python3-devel yum-priorities
RUN yum install -y http://repository.egi.eu/sw/production/umd/4/centos7/x86_64/updates/umd-release-4.1.3-1.el7.centos.noarch.rpm
RUN yum install -y ca-policy-egi-core fetch-crl
RUN systemctl enable fetch-crl-cron; systemctl start fetch-crl-cron
RUN fetch-crl -v
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 . /root/dirac_ui/bashrc && python -m pip install --upgrade pip setuptools wheel && python -m pip install --upgrade productionsystem@git+https://github.com/alexanderrichards/ProductionSystem.git@$productionsystem_version
RUN yum clean all

## setup cron jobs - maybe not needed if mounting from outside.
RUN echo "@daily userdb-update.py &>> /root/log/userdb-update.log" | crontab
RUN echo -e "[userdb]\ntrusted_cas='/etc/grid-security/certificates'" > /root/.config/productionsystem/productionsystem.conf
WORKDIR /root

COPY startup.sh /root/startup.sh

CMD ["all"]

ENTRYPOINT ["/root/startup.sh"]
38 changes: 38 additions & 0 deletions build/Dockerfileold
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# syntax = docker/dockerfile:1.0-experimental
from centos:8
ARG dirac_version=v6r22p6
ARG lcgtools_version=v14r1
ARG python_version=27
ARG productionsystem_version=master

RUN dnf swap -y coreutils-single coreutils # Fix for wrapper coreutils
RUN dnf install -y cronie 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 --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


## setup cron jobs - maybe not needed if mounting from outside.
RUN echo "@daily userdb-update.py &>> /root/log/userdb-update.log" | crontab

WORKDIR /root

COPY startup.sh /root/startup.sh

CMD ["all"]

ENTRYPOINT ["/root/startup.sh"]
4 changes: 4 additions & 0 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/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 .
63 changes: 63 additions & 0 deletions build/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/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
dirac)
echo "*** Starting DIRAC daemon. ***"
(. /root/dirac_ui/bashrc && dirac-daemon.py start)
;;
monitoring)
echo "*** Starting monitoring daemon. ***"
monitoring-daemon.py start
;;
webapp)
echo "*** Starting web app daemon. ***"
webapp-daemon.py start
;;
all)
start_daemon dirac
start_daemon monitoring
start_daemon webapp
;;
*)
echo "Unknown parameter: $1"
echo "Expected: {dirac|monitoring|webapp|all}"
exit 1
esac
}

crond
start_daemon $1
# Allow time to receive and process SIGTERM handler
while true
do
sleep 5
done
2 changes: 1 addition & 1 deletion scripts/dirac-daemon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
# pylint: disable=invalid-name
"""Dirac daemon run script."""
# Py2/3 compatibility layer
Expand Down
2 changes: 1 addition & 1 deletion scripts/monitoring-daemon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# pylint: disable=invalid-name
"""
DB monitoring daemon.
Expand Down
2 changes: 1 addition & 1 deletion scripts/userdb-update.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# pylint: disable=invalid-name
"""Script to read users info from VOMS and update locat SQL table."""
# Py2/3 compatibility layer
Expand Down
2 changes: 1 addition & 1 deletion scripts/webapp-daemon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# pylint: disable=invalid-name
"""Script to start the Production web server."""
# Py2/3 compatibility layer
Expand Down