From: Philipp Klaus Date: Sun, 5 Jul 2020 15:39:26 +0000 (+0200) Subject: restart_readout_service updated to docker-compose (file v3.8) X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=eb0a35cc57a63a068a14e015cbc19e1011ec9c48;p=mvd_epics.git restart_readout_service updated to docker-compose (file v3.8) --- diff --git a/python_suite/restart_readout_service/.gitignore b/python_suite/restart_readout_service/.gitignore new file mode 100644 index 0000000..e45e01a --- /dev/null +++ b/python_suite/restart_readout_service/.gitignore @@ -0,0 +1,2 @@ +username.txt +password.txt diff --git a/python_suite/restart_readout_service/Dockerfile b/python_suite/restart_readout_service/Dockerfile index 209ba8c..2ba70a5 100644 --- a/python_suite/restart_readout_service/Dockerfile +++ b/python_suite/restart_readout_service/Dockerfile @@ -1,38 +1,35 @@ -FROM pklaus/epics_base:debian-stretch +# syntax=docker/dockerfile:experimental +FROM alpine AS fetcher -ARG USERNAME -RUN test -n "$USERNAME" || (>&2 echo "--build-arg USERNAME=myusername is mandatory" && false) -ENV USERNAME=$USERNAME +RUN apk update && apk add git -ARG PASSWORD -RUN test -n "$PASSWORD" || (>&2 echo "--build-arg PASSWORD=mypassword is mandatory" && false) -ENV PASSWORD=$PASSWORD +RUN git clone https://github.com/pklaus/assert_epics_value_updates.git + +RUN rm -rf assert_epics_value_updates/.git -ARG EPICS_CA_ADDR_LIST -RUN test -n "$EPICS_CA_ADDR_LIST" || (>&2 echo "--build-arg EPICS_CA_ADDR_LIST=192.168.111.222 is mandatory" && false) -ENV EPICS_CA_ADDR_LIST=$EPICS_CA_ADDR_LIST -USER root +FROM ubuntu:20.04 -# Installing different required Debian packages: RUN apt-get update \ - && apt-get install --no-install-recommends -yq \ + && apt-get install --no-install-recommends --no-install-suggests -yq \ python3 \ python3-dev \ python3-setuptools \ python3-wheel \ python3-pip \ - # to get the repo: - git \ && apt-get clean && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt RUN ln -s /usr/bin/python3 /usr/bin/python \ && ln -s /usr/bin/pip3 /usr/bin/pip -RUN git clone https://github.com/pklaus/assert_epics_value_updates.git -WORKDIR assert_epics_value_updates +COPY --from=fetcher /assert_epics_value_updates/ /assert_epics_value_updates + +WORKDIR /assert_epics_value_updates + RUN pip install -r requirements.txt + ADD restart_readout.sh . + ADD run_restart_service.sh . -CMD /bin/bash -c ./run_restart_service.sh +CMD /bin/bash ./run_restart_service.sh diff --git a/python_suite/restart_readout_service/build.sh b/python_suite/restart_readout_service/build.sh index c82ce72..7c0c6c9 100755 --- a/python_suite/restart_readout_service/build.sh +++ b/python_suite/restart_readout_service/build.sh @@ -1,22 +1,6 @@ #!/bin/bash -echo "Please state username and password..." -echo "for the testgui at http://jspc55.x-matter.uni-frankfurt.de/mvdsensorcontrol/tools/testgui.pl?setup=PRESTO_2018_readout.xml" -echo "MIMOSA is the key!" +export DOCKER_BUILDKIT=1 +export COMPOSE_DOCKER_CLI_BUILD=1 -echo -n "USERNAME: " -read username - -echo -n "PASSWORD: " -read -s password - -echo "" -echo "username:password is $username:$password" - - -echo "HOST on which the mvd_trbnet IOC is running" -echo "(goes into environment variable EPICS_CA_ADDR_LIST):" -echo -n "EPICS_CA_ADDR_LIST: " -read epics_ca_addr_list - -docker build --build-arg USERNAME=$username --build-arg PASSWORD=$password --build-arg EPICS_CA_ADDR_LIST=$epics_ca_addr_list -t pklaus/mvd_restart_readout_service . +docker build -t pklaus/mvd_restart_readout_service . diff --git a/python_suite/restart_readout_service/docker-compose.yml b/python_suite/restart_readout_service/docker-compose.yml new file mode 100644 index 0000000..c862f5e --- /dev/null +++ b/python_suite/restart_readout_service/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.8' + +# This is using runtime secrets, see +# https://docs.docker.com/compose/compose-file/#secrets +# There's no equivalent docker CLI command as +# native `docker secret` commands are restricted +# to Docker swarm: +# https://serverfault.com/questions/871090/how-to-use-docker-secrets-without-a-swarm-cluster + +services: + restart-service: + image: pklaus/mvd_restart_readout_service + build: . + environment: + EPICS_CA_ADDR_LIST: 141.2.242.225 + network_mode: host + secrets: + - username + - password + restart: always + +secrets: + username: + file: username.txt + password: + file: password.txt diff --git a/python_suite/restart_readout_service/restart_readout.sh b/python_suite/restart_readout_service/restart_readout.sh index 481c5fd..4c95814 100755 --- a/python_suite/restart_readout_service/restart_readout.sh +++ b/python_suite/restart_readout_service/restart_readout.sh @@ -1,3 +1,11 @@ -#!/bin/bash +#!/bin/bash -e + +# username and password for the testgui at +# http://jspc55.x-matter.uni-frankfurt.de/mvdsensorcontrol/tools/testgui.pl?setup=PRESTO_2018_readout.xml +# MIMOSA is the key! + +# provide secrets as environment variable or they will be fetched from /run/secrets +USERNAME=${USERNAME:-$(cat /run/secrets/username)} +PASSWORD=${PASSWORD:-$(cat /run/secrets/password)} curl -u "$USERNAME:$PASSWORD" 'http://jspc55.x-matter.uni-frankfurt.de/mvdsensorcontrol/tools/run.pl?runtime=0.2&setupFile=%2Flocal.1%2Fhtdocs%2Fmvdsensorcontrol%2F..%2Fmvdconfig%2Fsetup%2F%2FPRESTO_2018_readout.xml'