Skip to content

Commit

Permalink
update to copier template 4.1.0b1
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 29, 2024
1 parent b7f04ff commit aaf24cd
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 3.6.1-7-gb5b6581
_commit: 4.1.0b1
_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
Expand Down
34 changes: 18 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
"remoteEnv": {
// provides a name for epics-containers to use in bash prompt etc.
"EC_PROJECT": "${localWorkspaceFolderBasename}",
"EPICS_CA_AUTO_ADDR_LIST": "NO",
"EPICS_CA_ADDR_LIST": "127.0.0.1"
"IOC_NAME": "DEV_TEST_IOC"
},
"features": {
// add quality of life features for developers including git config integration
"ghcr.io/devcontainers/features/common-utils:2": {
// don't upgrade to make this similar to the runtime container
"upgradePackages": false
}
// add in eternal history and other bash features
"ghcr.io/diamondlightsource/devcontainer-features/bash-config:1.0.0": {}
},
// IMPORTANT for this devcontainer to work with docker EC_REMOTE_USER must be
// set to your user name. You will run with full sudo rights.
// outside of the container setup
"initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}",
// IMPORTANT for this devcontainer to work with docker rootful
// EC_REMOTE_USER must be set to your user name. You will run with full
// sudo rights.
// For podman it should be left blank. You will run as root but host mounts
// will be owned by your user id.
"remoteUser": "${localEnv:EC_REMOTE_USER}",
Expand All @@ -35,25 +34,28 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.vscode-pylance",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"epicsdeb.vscode-epics",
"charliermarsh.ruff"
]
}
},
// You can place any outside of the container before-launch commands here
"initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}",
// One time global setup commands inside the container
"postCreateCommand": "bash .devcontainer/postCreateCommand ${devcontainerId}",
"runArgs": [
// IMPORTANT: this network must exist before the container is created
// source compose/environment.sh to create it before first use
"--network=channel_access_devcontainer",
// Make sure SELinux does not disable write access to host filesystems like tmp
"--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.
//
// 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"
],
// Mount the parent of the project folder so we can access peer projects
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// mount in other useful files from the host
Expand Down
15 changes: 9 additions & 6 deletions .devcontainer/initializeCommand
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
# custom initialization goes here - runs outside of the dev container
# just before the container is launched but after the container is created

FOLDER=$(dirname $(readlink -f $0))
echo "initializeCommand for devcontainerID ${1}"
set -xe

echo "devcontainerID ${1}"
# make the config folder for the shared bash-config feature
mkdir -p ${HOME}/.config/bash-config
# make a folder for auto-generated opi screens
mkdir -p ./opi/auto-generated

# ensure local container users can access X11 server
xhost +SI:localuser:$(id -un)

# make sure the shared network is created
# TODO this would be better done with compose but compose and podman
# in devcontainers is not currently stable.
source $FOLDER/../compose/environment.sh
2 changes: 1 addition & 1 deletion .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo 'source <(ibek --show-completion bash)' >> $HOME/.bashrc
echo 'source <(ibek --show-completion zsh)' >> $HOME/.zshrc

# pick theme and RPS1 with no unicode chars to avoid completion corruption in zsh
sed -i $HOME/.zshrc -e 's/ZSH_THEME="devcontainers"/ZSH_THEME="dst"/' -e '/^RPS1=/d'
sed -i $HOME/.zshrc -e 's/^ZSH_THEME.*$/ZSH_THEME="dst"/' -e '/^RPS1=/d'
# override the response PS - this shows the last exit code in red only
# echo "RPS1=$'%(?..%{\C-[[01;31m%}%? %{\C-[[00m%})'" >> $HOME/.zshrc

Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ ibek
# config folder is a container mount at /epics/ioc/config
ioc/config
# the opi folder is also mounted into the container at /epics/ioc/opi
opi/auto-generated/*
!opi/auto-generated/.placeholder
opi/auto-generated

# podman may leave this around in aborted builds
.build.swp
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generic IOC Template Repository ioc-pmac
# Generic IOC ioc-pmac

## Description
Generic IOC for the Delta Tau turbo pmac and power pmac motion controllers
Expand All @@ -21,14 +21,11 @@ copier update -a --trust .

This repository includes a developer container configuration for Visual Studio Code. This allows you to run the Generic IOC locally and debug it. See https://epics-containers.github.io/main/tutorials/dev_container.html.

### IMPORTANT: First Time Preparation
## Channel Access

The devcontainer uses a docker network that it can share with a ca-gateway in order that your PVs are accessible from your host machine. We arrange to create this network once and as long as you don't delete it or reset docker it will be available for all your devcontainers going forward.

To create the network run the following commands:
The developer container exposes channel access ports on the loopback interface. If you have channel access clients running on the host machine, you can connect to the IOC by setting the `EPICS_CA_ADDR_LIST` environment variable as follows:

```bash
cd ioc-adsimdetector
source ./compose/environment.sh
export EPICS_CA_ADDR_LIST=127.0.0.1
caget IOCNAME:PVNAME
```

10 changes: 8 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ fi

cd $(dirname ${0})

# use docker if available else use podman
if ! docker version &>/dev/null; then docker=podman; else docker=docker; fi
# 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
fi

if $docker buildx version &>/dev/null; then buildx=buildx; load=--load ; fi
if [[ $DOCKER_BUILDKIT == "0" ]]; then buildx=; load=; fi

Expand Down
11 changes: 0 additions & 11 deletions compose/compose.yaml

This file was deleted.

54 changes: 0 additions & 54 deletions compose/environment.sh

This file was deleted.

54 changes: 0 additions & 54 deletions compose/services/gateway/compose.yml

This file was deleted.

6 changes: 0 additions & 6 deletions compose/services/gateway/config/access

This file was deleted.

7 changes: 0 additions & 7 deletions compose/services/gateway/config/pvlist

This file was deleted.

34 changes: 0 additions & 34 deletions compose/services/phoebus/compose.yml

This file was deleted.

4 changes: 0 additions & 4 deletions compose/services/phoebus/config/settings.ini

This file was deleted.

Empty file removed opi/auto-generated/.placeholder
Empty file.
49 changes: 49 additions & 0 deletions opi/phoebus-launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# A launcher for the phoebus to view the generated OPIs

thisdir=$(realpath $(dirname $0))
workspace=$(realpath ${thisdir}/..)

settings="
-resource ${workspace}/opi/auto-generated/index.bob
-settings ${workspace}/opi/settings.ini
"

if which phoebus.sh &>/dev/null ; then
echo "Using phoebus.sh from PATH"
set -x
phoebus.sh ${settings} "${@}"

elif module load phoebus 2>/dev/null; then
echo "Using phoebus module"
set -x
phoebus.sh ${settings} "${@}"

else
echo "No local phoebus install found, using a container"

if podman version &> /dev/null && [[ -z $USE_DOCKER ]] ;
then docker=podman
else docker=docker
fi
echo "Using $docker as container runtime"

# ensure local container users can access X11 server
xhost +SI:localuser:$(id -un)

# settings for container launch
x11="-e DISPLAY --net host"
args=$"--rm -it --security-opt=label=none"
mounts="-v=/tmp:/tmp -v=${workspace}:/workspace"
image="ghcr.io/epics-containers/ec-phoebus:latest"

settings="
-settings /workspace/opi/settings.ini
-resource /workspace/opi/auto-generated/index.bob
"

set -x
$docker run ${mounts} ${args} ${x11} ${image} ${settings} "${@}"

fi
2 changes: 2 additions & 0 deletions opi/settings.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# point at local host for channel access
org.phoebus.pv.ca/addr_list=127.0.0.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ibek==3.0.1
ibek==3.1.0
# to install direct from github during development in a branch
# git+https://github.com/epics-containers/ibek.git@fix-extract-assets
Loading

0 comments on commit aaf24cd

Please sign in to comment.