--- /dev/null
+username.txt
+password.txt
-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
#!/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 .
--- /dev/null
+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
-#!/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'