From c6b61d2f9decc59afc0c11b7da0820cb07eedb24 Mon Sep 17 00:00:00 2001 From: giles knap Date: Mon, 2 Dec 2024 18:28:17 +0000 Subject: [PATCH 1/9] adding .env --- .env | 9 +++++++++ include/ioc.yml | 10 +++++++--- services/gateway/compose.yml | 14 ++++++-------- services/pvagw/compose.yml | 4 ---- 4 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..1e59684 --- /dev/null +++ b/.env @@ -0,0 +1,9 @@ +# +# Environment variables for the EPICS IOC ports. Make these unique if you +# want to run multiple compose beamlines on the same machine +# +EPICS_CA_NAME_SERVERS=localhost:5064 +EPICS_CA_SERVER_PORT=5064 +EPICS_CA_REPEATER_PORT=5065 +EPICS_PVA_NAME_SERVERS=localhost:5075 +EPICS_PVA_SERVER_PORT=5075 \ No newline at end of file diff --git a/include/ioc.yml b/include/ioc.yml index b1766a3..6fdb799 100644 --- a/include/ioc.yml +++ b/include/ioc.yml @@ -26,6 +26,13 @@ services: IOC_LOCATION: localhost BEAMLINE: bl01t IOC_GROUP: bl01t + # EPICS CA and PVA server ports + EPICS_PVA_NAME_SERVERS: ${EPICS_CA_NAME_SERVERS} + EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT} + EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT} + # EPICS_PVA_NAME_SERVERS: ${EPICS_CA_NAME_SERVERS:-127.0.0.1:5075} + # EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT:-5064} + # EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT:-5065} tty: true stdin_open: true @@ -39,9 +46,6 @@ services: networks: - channel_access - expose: - - "5064-5065/udp" - - "5064-5065" # proxy services that each manage an RTEMS hard IOC ########################## rtems_ioc: diff --git a/services/gateway/compose.yml b/services/gateway/compose.yml index e9a2842..c48c419 100644 --- a/services/gateway/compose.yml +++ b/services/gateway/compose.yml @@ -15,17 +15,14 @@ services: image: ghcr.io/epics-containers/docker-ca-gateway:2.1.3ec1 - expose: - - 5064-5065/udp - - 5064-5065 - security_opt: - label=disable ports: # bind to localhost to isolate channel access to this host only - - 127.0.0.1:5064:5064/udp - - 127.0.0.1:5064-5065:5064-5065 + - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT}/udp + - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT} + - 127.0.0.1:${EPICS_CA_REPEATER_PORT}:${EPICS_CA_REPEATER_PORT} restart: unless-stopped @@ -62,8 +59,9 @@ services: ports: # TODO - I need to look into safe config for per server ca-gateways - - 127.0.0.1:5064:5064/udp - - 127.0.0.1:5064-5065:5064-5065 + - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT}/udp + - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT} + - 127.0.0.1:${EPICS_CA_REPEATER_PORT}:${EPICS_CA_REPEATER_PORT} command: -cip 172.20.255.255 -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1 diff --git a/services/pvagw/compose.yml b/services/pvagw/compose.yml index f029c5a..d87b04b 100644 --- a/services/pvagw/compose.yml +++ b/services/pvagw/compose.yml @@ -9,10 +9,6 @@ services: image: ghcr.io/epics-containers/ec-p4p:4.1.12ec1 - expose: - - 5076/udp - - 5075 - ports: # bind to localhost to isolate channel access to this host only - 127.0.0.1:5076:5076/udp From 401a8dd3b2e0408b23287269071af89a8d588c36 Mon Sep 17 00:00:00 2001 From: giles knap Date: Mon, 2 Dec 2024 19:38:35 +0000 Subject: [PATCH 2/9] get PVA working --- .env | 9 --- environment.sh | 10 +++ opi/demo.bob | 84 ++++++++++++------------ services/bl01t-di-cam-01/config/ioc.yaml | 1 + services/phoebus/compose.yml | 1 - services/phoebus/config/settings.ini | 6 +- services/pvagw/compose.yml | 13 ++-- 7 files changed, 61 insertions(+), 63 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 1e59684..0000000 --- a/.env +++ /dev/null @@ -1,9 +0,0 @@ -# -# Environment variables for the EPICS IOC ports. Make these unique if you -# want to run multiple compose beamlines on the same machine -# -EPICS_CA_NAME_SERVERS=localhost:5064 -EPICS_CA_SERVER_PORT=5064 -EPICS_CA_REPEATER_PORT=5065 -EPICS_PVA_NAME_SERVERS=localhost:5075 -EPICS_PVA_SERVER_PORT=5075 \ No newline at end of file diff --git a/environment.sh b/environment.sh index 87435e7..015f8ba 100755 --- a/environment.sh +++ b/environment.sh @@ -14,6 +14,16 @@ if [ "$0" = "$BASH_SOURCE" ]; then exit 1 fi +# Environment variables for the EPICS IOC ports. Make these unique if you +# want to run multiple compose beamlines on the same machine +# +export EPICS_CA_SERVER_PORT=5064 +export EPICS_CA_REPEATER_PORT=5065 +export EPICS_PVA_SERVER_PORT=5075 +export EPICS_PVA_NAME_SERVERS=localhost:${EPICS_PVA_SERVER_PORT} +export EPICS_CA_NAME_SERVERS=localhost:${EPICS_CA_SERVER_PORT} +export EPICS_CA_ADDR_LIST=127.0.0.1 + # if there is a docker-compose module then load it if [[ $(module avail docker-compose 2>/dev/null) != "" ]] ; then module load docker-compose diff --git a/opi/demo.bob b/opi/demo.bob index 991c7cb..a9a36b2 100644 --- a/opi/demo.bob +++ b/opi/demo.bob @@ -1,5 +1,5 @@ - + Example IOCs 388 @@ -372,47 +372,6 @@ $(text) - - Image - BL01T-DI-CAM-01:ARR:ArrayData - 396 - 36 - 670 - 670 - true - - false - SimDetector Image - 0.0 - 1024.0 - - - - - - - - - - - false - Y - 0.0 - 1024.0 - - - - - - - - - - 1024 - 1024 - true - true - Autogenerated Engineering Screens @@ -579,4 +538,45 @@ 77 + + Image_1 + pva://BL01T-DI-CAM-01:PVA:OUTPUT + 402 + 36 + 670 + 670 + true + + false + SimDetector Image + 0.0 + 1024.0 + + + + + + + + + + + false + Y + 0.0 + 1024.0 + + + + + + + + + + 1024 + 1024 + true + true + diff --git a/services/bl01t-di-cam-01/config/ioc.yaml b/services/bl01t-di-cam-01/config/ioc.yaml index beac6e8..93f22b4 100644 --- a/services/bl01t-di-cam-01/config/ioc.yaml +++ b/services/bl01t-di-cam-01/config/ioc.yaml @@ -22,6 +22,7 @@ entities: dbpf BL01T-DI-CAM-01:ARR:EnableCallbacks 1 dbpf BL01T-DI-CAM-01:PROC:EnableCallbacks 1 dbpf BL01T-DI-CAM-01:ROI:EnableCallbacks 1 + dbpf BL01T-DI-CAM-01:PVA:EnableCallbacks 1 dbpf BL01T-DI-CAM-01:DET:Acquire 1 - type: ADCore.NDROI diff --git a/services/phoebus/compose.yml b/services/phoebus/compose.yml index d3af484..7f90e52 100644 --- a/services/phoebus/compose.yml +++ b/services/phoebus/compose.yml @@ -12,7 +12,6 @@ services: command: phoebus-product/phoebus.sh -settings /config/settings.ini -resource /opi/demo.bob -server 7010 volumes: - /tmp/.X11-unix:/tmp/.X11-unix - - ~/.Xauthority:/root/.Xauthority - ../../opi:/opi - ../../..:/workspaces diff --git a/services/phoebus/config/settings.ini b/services/phoebus/config/settings.ini index c4d462b..ec59cf4 100644 --- a/services/phoebus/config/settings.ini +++ b/services/phoebus/config/settings.ini @@ -1,4 +1,6 @@ # using localhost for channel access to isolate it to the host for development - -# TODO restore this once we have PVA gateway and IOCS running in the CNI org.phoebus.pv.ca/addr_list=127.0.0.1 +org.phoebus.pv.ca/server_port=5064 +org.phoebus.pv.ca/repeater_port=5065 +org.phoebus.pv.pva/server_port=5075 +org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1 diff --git a/services/pvagw/compose.yml b/services/pvagw/compose.yml index d87b04b..ac4bf1d 100644 --- a/services/pvagw/compose.yml +++ b/services/pvagw/compose.yml @@ -10,9 +10,7 @@ services: image: ghcr.io/epics-containers/ec-p4p:4.1.12ec1 ports: - # bind to localhost to isolate channel access to this host only - - 127.0.0.1:5076:5076/udp - - 127.0.0.1:5075:5075 + - 127.0.0.1:${EPICS_PVA_SERVER_PORT}:${EPICS_PVA_SERVER_PORT} restart: unless-stopped @@ -26,10 +24,8 @@ services: command: -c "pvagw /config/pvagw.config --debug" profiles: - # PVAcess cannot set up channels into a container yet, so we are using - # ndstdarrys instead of ndpva for now - # https://github.com/epics-base/pvAccessCPP/issues/197 - - removed + - test + - dev # per server pvagw for deployment ############################################# pvagw-deploy: @@ -38,8 +34,7 @@ services: ports: # TODO investigate how to configure this for deployment - - 127.0.0.1:5076:5076/udp - - 127.0.0.1:5075:5075 + - 127.0.0.1:${EPICS_PVA_SERVER_PORT}:${EPICS_PVA_SERVER_PORT} command: -c "pvagw /config/pvagw.config" From 97b37a8c7abd211b01b7587d9bf9800c30314fe8 Mon Sep 17 00:00:00 2001 From: giles knap Date: Mon, 2 Dec 2024 20:12:47 +0000 Subject: [PATCH 3/9] make net and ports configurable --- environment.sh | 18 +++++++++++++----- include/ioc.yml | 7 ------- include/networks.yml | 2 +- services/gateway/compose.yml | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/environment.sh b/environment.sh index 015f8ba..d1d5153 100755 --- a/environment.sh +++ b/environment.sh @@ -14,14 +14,22 @@ if [ "$0" = "$BASH_SOURCE" ]; then exit 1 fi -# Environment variables for the EPICS IOC ports. Make these unique if you -# want to run multiple compose beamlines on the same machine +# Environment variables for the EPICS IOC ports. Pick a Unique BASE +# to allow multiple compose beamlines to run on the same host. +# BASE values should be separated by 20. # -export EPICS_CA_SERVER_PORT=5064 -export EPICS_CA_REPEATER_PORT=5065 -export EPICS_PVA_SERVER_PORT=5075 +BASE=5064 +# +export EPICS_CA_SERVER_PORT=$BASE # defaults to 5064 +export EPICS_CA_REPEATER_PORT=$(($BASE+1)) # defaults to 5065 +export EPICS_PVA_SERVER_PORT=$(($BASE+11)) # defaults to 5075 + +export CA_SUBNET=170.$(($BASE % 256)).0.0/16 +export CA_BROADCAST=170.$(($BASE % 256)).255.255 + export EPICS_PVA_NAME_SERVERS=localhost:${EPICS_PVA_SERVER_PORT} export EPICS_CA_NAME_SERVERS=localhost:${EPICS_CA_SERVER_PORT} + export EPICS_CA_ADDR_LIST=127.0.0.1 # if there is a docker-compose module then load it diff --git a/include/ioc.yml b/include/ioc.yml index 6fdb799..7cb0bfd 100644 --- a/include/ioc.yml +++ b/include/ioc.yml @@ -26,13 +26,6 @@ services: IOC_LOCATION: localhost BEAMLINE: bl01t IOC_GROUP: bl01t - # EPICS CA and PVA server ports - EPICS_PVA_NAME_SERVERS: ${EPICS_CA_NAME_SERVERS} - EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT} - EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT} - # EPICS_PVA_NAME_SERVERS: ${EPICS_CA_NAME_SERVERS:-127.0.0.1:5075} - # EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT:-5064} - # EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT:-5065} tty: true stdin_open: true diff --git a/include/networks.yml b/include/networks.yml index 6d9ce15..607aa8c 100644 --- a/include/networks.yml +++ b/include/networks.yml @@ -4,4 +4,4 @@ networks: ipam: driver: default config: - - subnet: "172.20.0.0/16" + - subnet: "${CA_SUBNET}" diff --git a/services/gateway/compose.yml b/services/gateway/compose.yml index c48c419..bd3f8d0 100644 --- a/services/gateway/compose.yml +++ b/services/gateway/compose.yml @@ -33,7 +33,7 @@ services: - source: ca-gateway_config target: /config - command: -cip 172.20.255.255 -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1 + command: -cip ${CA_BROADCAST} -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1 profiles: - test @@ -63,7 +63,7 @@ services: - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT} - 127.0.0.1:${EPICS_CA_REPEATER_PORT}:${EPICS_CA_REPEATER_PORT} - command: -cip 172.20.255.255 -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1 + command: -cip ${CA_BROADCAST} -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1 profiles: - deploy From 4c420a436f8b8f1f6788ad3f3482071e0882073d Mon Sep 17 00:00:00 2001 From: giles knap Date: Mon, 2 Dec 2024 20:37:40 +0000 Subject: [PATCH 4/9] move settings files to templates --- services/phoebus/config/{settings.ini => settings.template} | 0 services/pvagw/compose.yml | 4 ++++ services/pvagw/config/{pvagw.config => pvagw.config.template} | 0 3 files changed, 4 insertions(+) rename services/phoebus/config/{settings.ini => settings.template} (100%) rename services/pvagw/config/{pvagw.config => pvagw.config.template} (100%) diff --git a/services/phoebus/config/settings.ini b/services/phoebus/config/settings.template similarity index 100% rename from services/phoebus/config/settings.ini rename to services/phoebus/config/settings.template diff --git a/services/pvagw/compose.yml b/services/pvagw/compose.yml index ac4bf1d..f5839da 100644 --- a/services/pvagw/compose.yml +++ b/services/pvagw/compose.yml @@ -12,6 +12,10 @@ services: ports: - 127.0.0.1:${EPICS_PVA_SERVER_PORT}:${EPICS_PVA_SERVER_PORT} + environment: + - EPICS_PVA_SERVER_PORT=${EPICS_PVA_SERVER_PORT} + - EPICS_PVAS_SERVER_PORT=${EPICS_PVA_SERVER_PORT} + restart: unless-stopped networks: diff --git a/services/pvagw/config/pvagw.config b/services/pvagw/config/pvagw.config.template similarity index 100% rename from services/pvagw/config/pvagw.config rename to services/pvagw/config/pvagw.config.template From 16d345a6029528a34b9ec08c43b99094c460210a Mon Sep 17 00:00:00 2001 From: giles knap Date: Mon, 2 Dec 2024 21:02:48 +0000 Subject: [PATCH 5/9] get templated config files fully working --- .gitignore | 5 +++++ environment.sh | 22 +++++++++++++------ include/ioc.yml | 3 +++ services/gateway/compose.yml | 4 ++++ services/phoebus/config/settings.template | 4 ++-- .../{pvagw.config.template => pvagw.template} | 0 6 files changed, 29 insertions(+), 9 deletions(-) rename services/pvagw/config/{pvagw.config.template => pvagw.template} (100%) diff --git a/.gitignore b/.gitignore index 6236544..122d083 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,8 @@ venv* # and is created at runtime by IOCs using PVI opi/auto-generated/* !opi/auto-generated/README.md + +# these files are generated from templates +# when sourcing environment.sh +services/pvagw/config/pvagw.config +services/phoebus/config/settings.ini diff --git a/environment.sh b/environment.sh index d1d5153..fd52ade 100755 --- a/environment.sh +++ b/environment.sh @@ -18,20 +18,29 @@ fi # to allow multiple compose beamlines to run on the same host. # BASE values should be separated by 20. # -BASE=5064 +BASE=5094 # default would usually be 5064 # -export EPICS_CA_SERVER_PORT=$BASE # defaults to 5064 -export EPICS_CA_REPEATER_PORT=$(($BASE+1)) # defaults to 5065 -export EPICS_PVA_SERVER_PORT=$(($BASE+11)) # defaults to 5075 +export EPICS_CA_SERVER_PORT=$BASE # default 5064 +export EPICS_CA_REPEATER_PORT=$(( $BASE + 1 )) # default 5065 +export EPICS_PVA_SERVER_PORT=$(( $BASE + 11 )) # default 5075 -export CA_SUBNET=170.$(($BASE % 256)).0.0/16 -export CA_BROADCAST=170.$(($BASE % 256)).255.255 +export CA_SUBNET=170.$(( $BASE % 256 )).0.0/16 +export CA_BROADCAST=170.$(( $BASE % 256 )).255.255 export EPICS_PVA_NAME_SERVERS=localhost:${EPICS_PVA_SERVER_PORT} export EPICS_CA_NAME_SERVERS=localhost:${EPICS_CA_SERVER_PORT} export EPICS_CA_ADDR_LIST=127.0.0.1 +# update configuration files that depend on the above environment variables +cat services/phoebus/config/settings.template | + sed -e "s/5064/$EPICS_CA_SERVER_PORT/g" \ + -e "s/5065/$EPICS_CA_REPEATER_PORT/g" \ + -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > services/phoebus/config/settings.ini +cat services/pvagw/config/pvagw.template | + sed -e "s/172.20.255.255/$CA_BROADCAST/g" \ + -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > services/pvagw/config/pvagw.config + # if there is a docker-compose module then load it if [[ $(module avail docker-compose 2>/dev/null) != "" ]] ; then module load docker-compose @@ -47,7 +56,6 @@ else unset DOCKER_HOST docker=docker fi - echo using $docker as container engine # ensure local container users can access X11 server diff --git a/include/ioc.yml b/include/ioc.yml index 7cb0bfd..e159027 100644 --- a/include/ioc.yml +++ b/include/ioc.yml @@ -26,6 +26,9 @@ services: IOC_LOCATION: localhost BEAMLINE: bl01t IOC_GROUP: bl01t + EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT} + EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT} + EPICS_PVA_SERVER_PORT: ${EPICS_PVA_SERVER_PORT} tty: true stdin_open: true diff --git a/services/gateway/compose.yml b/services/gateway/compose.yml index bd3f8d0..6bd18ed 100644 --- a/services/gateway/compose.yml +++ b/services/gateway/compose.yml @@ -24,6 +24,10 @@ services: - 127.0.0.1:${EPICS_CA_SERVER_PORT}:${EPICS_CA_SERVER_PORT} - 127.0.0.1:${EPICS_CA_REPEATER_PORT}:${EPICS_CA_REPEATER_PORT} + environment: + EPICS_CA_SERVER_PORT: ${EPICS_CA_SERVER_PORT} + EPICS_CA_REPEATER_PORT: ${EPICS_CA_REPEATER_PORT} + restart: unless-stopped networks: diff --git a/services/phoebus/config/settings.template b/services/phoebus/config/settings.template index ec59cf4..21dadbe 100644 --- a/services/phoebus/config/settings.template +++ b/services/phoebus/config/settings.template @@ -1,6 +1,6 @@ # using localhost for channel access to isolate it to the host for development -org.phoebus.pv.ca/addr_list=127.0.0.1 +org.phoebus.pv.ca/addr_list=127.0.0.1:5064 org.phoebus.pv.ca/server_port=5064 org.phoebus.pv.ca/repeater_port=5065 org.phoebus.pv.pva/server_port=5075 -org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1 +org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1:5075 diff --git a/services/pvagw/config/pvagw.config.template b/services/pvagw/config/pvagw.template similarity index 100% rename from services/pvagw/config/pvagw.config.template rename to services/pvagw/config/pvagw.template From ef9755fcc80f9a29ee0e3c71f1548c4cb0aa42a3 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 3 Dec 2024 07:42:15 +0000 Subject: [PATCH 6/9] remove network name (avoids name clashes) --- include/networks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/include/networks.yml b/include/networks.yml index 607aa8c..f0647a8 100644 --- a/include/networks.yml +++ b/include/networks.yml @@ -1,6 +1,5 @@ networks: channel_access: - name: "channel_access" ipam: driver: default config: From 680f01fc04fa8f1f80e903a0f6a576df8cf43981 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 3 Dec 2024 07:48:13 +0000 Subject: [PATCH 7/9] add security opt to pvagw --- services/pvagw/compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/pvagw/compose.yml b/services/pvagw/compose.yml index f5839da..eeb2cf2 100644 --- a/services/pvagw/compose.yml +++ b/services/pvagw/compose.yml @@ -9,6 +9,9 @@ services: image: ghcr.io/epics-containers/ec-p4p:4.1.12ec1 + security_opt: + - label=disable + ports: - 127.0.0.1:${EPICS_PVA_SERVER_PORT}:${EPICS_PVA_SERVER_PORT} From 97ebe29c076eed126c481445d18465d7f622dfac Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 3 Dec 2024 08:22:58 +0000 Subject: [PATCH 8/9] use .env and init container --- .env | 17 +++++++++++++++++ compose.yaml | 19 +++++++++++++++++++ environment.sh | 30 +----------------------------- include/init.sh | 18 ++++++++++++++++++ services/phoebus/compose.yml | 2 ++ services/pvagw/compose.yml | 3 +++ 6 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 .env create mode 100755 include/init.sh diff --git a/.env b/.env new file mode 100644 index 0000000..1abeb0a --- /dev/null +++ b/.env @@ -0,0 +1,17 @@ +# Environment variables for the EPICS IOC ports. Pick a Unique values +# to allow multiple compose beamlines to run on the same host. +EPICS_CA_SERVER_PORT=5094 +EPICS_CA_REPEATER_PORT=5095 +EPICS_PVA_SERVER_PORT=5105 + +# unique subnet for this compose project +CA_SUBNET=170.200.0.0/16 +CA_BROADCAST=170.200.255.255 + +# EPICS name server configuration - do not change +EPICS_PVA_NAME_SERVERS=localhost:${EPICS_PVA_SERVER_PORT} +EPICS_CA_NAME_SERVERS=localhost:${EPICS_CA_SERVER_PORT} + +# clients outside of containers should use this address list +# to access local containers with this configuration and with default ports too +EPICS_CA_ADDR_LIST="127.0.0.1:${EPICS_PVA_SERVER_PORT} 127.0.0.1:5064" diff --git a/compose.yaml b/compose.yaml index 5585d3d..4189bd2 100644 --- a/compose.yaml +++ b/compose.yaml @@ -27,3 +27,22 @@ include: # deploy profile only - services/epics-opis/compose.yml + +services: + init: + image: ubuntu + security_opt: + - label=disable + restart: never + volumes: + - .:/workspace + command: /bin/bash -c "/workspace/include/init.sh" + environment: + - EPICS_CA_SERVER_PORT + - EPICS_CA_REPEATER_PORT + - EPICS_PVA_SERVER_PORT + - CA_SUBNET + - CA_BROADCAST + - EPICS_PVA_NAME_SERVERS + - EPICS_CA_NAME_SERVERS + - EPICS_CA_ADDR_LIST diff --git a/environment.sh b/environment.sh index fd52ade..211899f 100755 --- a/environment.sh +++ b/environment.sh @@ -7,40 +7,12 @@ # docker compose may be backed by podman or docker container engines, see # https://epics-containers.github.io/main/tutorials/setup_workstation.html. - # This script must be sourced if [ "$0" = "$BASH_SOURCE" ]; then echo "ERROR: Please source this script (source ./environment.sh)" exit 1 fi -# Environment variables for the EPICS IOC ports. Pick a Unique BASE -# to allow multiple compose beamlines to run on the same host. -# BASE values should be separated by 20. -# -BASE=5094 # default would usually be 5064 -# -export EPICS_CA_SERVER_PORT=$BASE # default 5064 -export EPICS_CA_REPEATER_PORT=$(( $BASE + 1 )) # default 5065 -export EPICS_PVA_SERVER_PORT=$(( $BASE + 11 )) # default 5075 - -export CA_SUBNET=170.$(( $BASE % 256 )).0.0/16 -export CA_BROADCAST=170.$(( $BASE % 256 )).255.255 - -export EPICS_PVA_NAME_SERVERS=localhost:${EPICS_PVA_SERVER_PORT} -export EPICS_CA_NAME_SERVERS=localhost:${EPICS_CA_SERVER_PORT} - -export EPICS_CA_ADDR_LIST=127.0.0.1 - -# update configuration files that depend on the above environment variables -cat services/phoebus/config/settings.template | - sed -e "s/5064/$EPICS_CA_SERVER_PORT/g" \ - -e "s/5065/$EPICS_CA_REPEATER_PORT/g" \ - -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > services/phoebus/config/settings.ini -cat services/pvagw/config/pvagw.template | - sed -e "s/172.20.255.255/$CA_BROADCAST/g" \ - -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > services/pvagw/config/pvagw.config - # if there is a docker-compose module then load it if [[ $(module avail docker-compose 2>/dev/null) != "" ]] ; then module load docker-compose @@ -65,7 +37,7 @@ xhost +SI:localuser:$(id -un) # set user id for the phoebus container for easy X11 forwarding. export UIDGID=$USER_ID:$USER_GID -# choose test profile for docker compose +# default to the test profile for docker compose export COMPOSE_PROFILES=test # for test profile our ca-gateway publishes PVS on the loopback interface export EPICS_CA_ADDR_LIST=127.0.0.1 diff --git a/include/init.sh b/include/init.sh new file mode 100755 index 0000000..c2abe47 --- /dev/null +++ b/include/init.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +root=$(realpath $(dirname $0)/..) + +echo "setting up configuration file for pva gateway" + +cat $root/services/pvagw/config/pvagw.template | + sed -e "s/172.20.255.255/$CA_BROADCAST/g" \ + -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > \ + $root/services/pvagw/config/pvagw.config + +echo "setting up configuration file for phoebus" + +cat $root/services/phoebus/config/settings.template | + sed -e "s/5064/$EPICS_CA_SERVER_PORT/g" \ + -e "s/5065/$EPICS_CA_REPEATER_PORT/g" \ + -e "s/5075/$EPICS_PVA_SERVER_PORT/g" > \ + $root/services/phoebus/config/settings.ini \ No newline at end of file diff --git a/services/phoebus/compose.yml b/services/phoebus/compose.yml index 7f90e52..7cd0b74 100644 --- a/services/phoebus/compose.yml +++ b/services/phoebus/compose.yml @@ -5,6 +5,8 @@ services: phoebus: container_name: phoebus image: ghcr.io/epics-containers/ec-phoebus:4.7.3ec2 + depends_on: + - init environment: DISPLAY: $DISPLAY tty: true diff --git a/services/pvagw/compose.yml b/services/pvagw/compose.yml index eeb2cf2..da73d4c 100644 --- a/services/pvagw/compose.yml +++ b/services/pvagw/compose.yml @@ -9,6 +9,9 @@ services: image: ghcr.io/epics-containers/ec-p4p:4.1.12ec1 + depends_on: + - init + security_opt: - label=disable From ccc1a528472e900815a97cf2f82e89868863f74f Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 3 Dec 2024 08:42:14 +0000 Subject: [PATCH 9/9] add default for UIDGID --- .env | 4 ++-- services/phoebus/compose.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 1abeb0a..6f88e68 100644 --- a/.env +++ b/.env @@ -1,10 +1,10 @@ -# Environment variables for the EPICS IOC ports. Pick a Unique values +# Environment variables for the EPICS IOC ports. Pick unique values # to allow multiple compose beamlines to run on the same host. EPICS_CA_SERVER_PORT=5094 EPICS_CA_REPEATER_PORT=5095 EPICS_PVA_SERVER_PORT=5105 -# unique subnet for this compose project +# unique subnet for this compose project, broadcast must match the subnet CA_SUBNET=170.200.0.0/16 CA_BROADCAST=170.200.255.255 diff --git a/services/phoebus/compose.yml b/services/phoebus/compose.yml index 7cd0b74..634cf42 100644 --- a/services/phoebus/compose.yml +++ b/services/phoebus/compose.yml @@ -9,6 +9,8 @@ services: - init environment: DISPLAY: $DISPLAY + UIDGID: ${UIDGID:-0:0} # defaults to working with rootless + tty: true # pick a server port for phoebus so it does not reconnect to existing phoebus command: phoebus-product/phoebus.sh -settings /config/settings.ini -resource /opi/demo.bob -server 7010