From c200daad254ba15ebf68eca032dc6f13deeba9e4 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Mon, 2 Dec 2024 10:37:36 +0000 Subject: [PATCH] update to copier 4.1.0b4 --- .copier-answers.yml | 2 +- .devcontainer/.env | 3 +++ .devcontainer/devcontainer.json | 18 +++++++++++------- build | 19 +++++++++---------- opi/phoebus-launch.sh | 23 ++++++++++++++++------- opi/settings.ini | 9 +++++++++ tests/run-tests.sh | 9 ++++----- 7 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 .devcontainer/.env diff --git a/.copier-answers.yml b/.copier-answers.yml index 213cd3f..b11b3af 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 4.1.0b1 +_commit: 4.1.0b4 _src_path: gh:epics-containers/ioc-template description: Generic IOC for the Delta Tau turbo pmac and power pmac motion controllers git_platform: github.com diff --git a/.devcontainer/.env b/.devcontainer/.env new file mode 100644 index 0000000..bbb52d3 --- /dev/null +++ b/.devcontainer/.env @@ -0,0 +1,3 @@ +EPICS_CA_SERVER_PORT=5064 +EPICS_CA_REPEATER_PORT=5065 +EPICS_PVA_SERVER_PORT=5075 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cb296a4..7b002d7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -47,14 +47,18 @@ "--security-opt=label=disable" ], "appPort": [ - // Expose Channel Access on the hosts loopback interface - // NOTE: change the first port number to run more than one devcontainer - // on the same host. + // Expose Channel Access ports on the host's loopback interface + // Note: update the environment variables in .devcontainer/.env to + // change the ports when running multiple devcontainers simultaneously, + // then use e.g. EPICS_CA_ADDR_LIST="127.0.0.1:5064 127.0.0.1:6064" + // for clients to connect to multiple devcontainers' PVs. // - // To access two devcontainers from the host for example: - // EPICS_CA_ADDR_LIST="127.0.0.1:5064 127.0.0.1:6064" - "127.0.0.1:5064:5064/udp", - "127.0.0.1:5064-5065:5064-5065" + "127.0.0.1:${remoteEnv:EPICS_CA_SERVER_PORT}:${remoteEnv:EPICS_CA_SERVER_PORT}/udp", + "127.0.0.1:${remoteEnv:EPICS_CA_SERVER_PORT}:${remoteEnv:EPICS_CA_SERVER_PORT}", + "127.0.0.1:${remoteEnv:EPICS_CA_REPEATER_PORT}:${remoteEnv:EPICS_CA_REPEATER_PORT}", + // + // Expose the PVA name server port on all host interfaces + "${remoteEnv:EPICS_PVA_SERVER_PORT}:${remoteEnv:EPICS_PVA_SERVER_PORT}" ], // Mount the parent of the project folder so we can access peer projects "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", diff --git a/build b/build index 0e6b1c8..f02a6a7 100755 --- a/build +++ b/build @@ -23,19 +23,18 @@ cd $(dirname ${0}) # make sure the ioc binaries and config symlink are cleaned up git clean -fdx ioc -if podman version &> /dev/null && [[ -z $USE_DOCKER ]] - then docker=podman - else docker=docker +# prefer docker but use podman if USE_PODMAN is set +if docker version &> /dev/null && [[ -z $USE_PODMAN ]] + then docker=docker + else docker=podman fi -if $docker buildx version &>/dev/null; then buildx=buildx; load=--load ; fi -if [[ $DOCKER_BUILDKIT == "0" ]]; then buildx=; load=; fi - # make sure new repos get their submodule ibek-support if [ ! -d ibek-support/_global ] ; then git submodule update --init ; fi -# build and developer images +# build runtime or developer image set -x -$docker $buildx build -t ${TAG} "${@}" $load \ - --build-arg IMAGE_EXT=$IMAGE_EXT \ - $runtime --target $TARGET . +$docker build -t ${TAG} "${@}" --build-arg IMAGE_EXT=$IMAGE_EXT \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg EPICS_TARGET_ARCH=$T_A \ + --load --target $TARGET . diff --git a/opi/phoebus-launch.sh b/opi/phoebus-launch.sh index 98a7cf9..c1e4060 100755 --- a/opi/phoebus-launch.sh +++ b/opi/phoebus-launch.sh @@ -5,9 +5,17 @@ thisdir=$(realpath $(dirname $0)) workspace=$(realpath ${thisdir}/..) +# update settings.ini with CA and PVA ports +source ${workspace}/.devcontainer/.env +cat ${workspace}/opi/settings.ini | + sed -r \ + -e "s|5064|${EPICS_CA_SERVER_PORT}|" \ + -e "s|5075|${EPICS_PVA_SERVER_PORT}|" \ + -e "s|5065|${EPICS_CA_REPEATER_PORT}|" > /tmp/settings.ini + settings=" -resource ${workspace}/opi/auto-generated/index.bob --settings ${workspace}/opi/settings.ini +-settings /tmp/settings.ini " if which phoebus.sh &>/dev/null ; then @@ -23,9 +31,10 @@ elif module load phoebus 2>/dev/null; then else echo "No local phoebus install found, using a container" - if podman version &> /dev/null && [[ -z $USE_DOCKER ]] ; - then docker=podman - else docker=docker + # prefer docker but use podman if USE_PODMAN is set + if docker version &> /dev/null && [[ -z $USE_PODMAN ]] + then docker=docker; UIDGID=$(id -u):$(id -g) + else docker=podman; UIDGID=0:0 fi echo "Using $docker as container runtime" @@ -34,13 +43,13 @@ else # settings for container launch x11="-e DISPLAY --net host" - args=$"--rm -it --security-opt=label=none" - mounts="-v=/tmp:/tmp -v=${workspace}:/workspace" + args="--rm -it --security-opt=label=none --user ${UIDGID}" + mounts="-v=/tmp:/tmp -v=${workspace}:/workspace -v=${workspace}/..:/workspaces" image="ghcr.io/epics-containers/ec-phoebus:latest" settings=" - -settings /workspace/opi/settings.ini -resource /workspace/opi/auto-generated/index.bob + -settings /tmp/settings.ini " set -x diff --git a/opi/settings.ini b/opi/settings.ini index a8fb091..abd3c00 100644 --- a/opi/settings.ini +++ b/opi/settings.ini @@ -1,2 +1,11 @@ +# NOTE: port numbers are defaults only +# this script to be processed with sed to replace port numbers +# see phoebus-launch.sh + # point at local host for channel access org.phoebus.pv.ca/addr_list=127.0.0.1 +org.phoebus.pv.ca/server_port=5064 +org.phoebus.pv.ca/repeater_port=5065 +# point at local host for pvAccess name server +org.phoebus.pv.pva/epics_pva_name_servers=127.0.0.1 +org.phoebus.pv.pva/server_port=5075 diff --git a/tests/run-tests.sh b/tests/run-tests.sh index b7a7b69..7be4f65 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -13,9 +13,10 @@ CONF=/epics/ioc/config # log commands and stop on errorsr set -ex -if podman version &> /dev/null && [[ -z $USE_DOCKER ]] - then docker=podman - else docker=docker +# prefer docker but use podman if USE_PODMAN is set +if docker version &> /dev/null && [[ -z $USE_PODMAN ]] + then docker=docker + else docker=podman fi cd ${ROOT} @@ -39,5 +40,3 @@ fi echo "Tests passed!" - -