]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
restart_readout_service updated to docker-compose (file v3.8)
authorPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Sun, 5 Jul 2020 15:39:26 +0000 (17:39 +0200)
committerPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Sun, 5 Jul 2020 15:39:26 +0000 (17:39 +0200)
python_suite/restart_readout_service/.gitignore [new file with mode: 0644]
python_suite/restart_readout_service/Dockerfile
python_suite/restart_readout_service/build.sh
python_suite/restart_readout_service/docker-compose.yml [new file with mode: 0644]
python_suite/restart_readout_service/restart_readout.sh

diff --git a/python_suite/restart_readout_service/.gitignore b/python_suite/restart_readout_service/.gitignore
new file mode 100644 (file)
index 0000000..e45e01a
--- /dev/null
@@ -0,0 +1,2 @@
+username.txt
+password.txt
index 209ba8c7b3a33f492fb363ea1176b1e77484b4db..2ba70a594c46d59e4815203646e73b209d0f239c 100644 (file)
@@ -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
index c82ce721d79c4f2d0cc5b44d390258d2d7bb30d8..7c0c6c9d8b03b6577411a0082925e4c997babd71 100755 (executable)
@@ -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 (file)
index 0000000..c862f5e
--- /dev/null
@@ -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
index 481c5fd14c85d8b7217a0013ca0e27f5e029e158..4c958143b0c5af8094613d772a57ffdcdeb1da43 100755 (executable)
@@ -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'