Skip to content

Commit

Permalink
Merge pull request #4 from epics-containers/copier
Browse files Browse the repository at this point in the history
Adopt copier and add motorSim IOC
  • Loading branch information
gilesknap authored Aug 26, 2024
2 parents 4b1e8c3 + 22b9c24 commit 18b9b49
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 3.6.0-2-g556dcca
_src_path: gh:epics-containers/services-template-compose
description: example IOC Instances and Services using docker compose
services: example
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ venv*

# this is the root directory for generated opi files
# and is created at runtime by IOCs using PVI
opi/iocs
!opi/iocs/README.md
opi/auto-generated/*
!opi/auto-generated/README.md
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include:
# all profiles
- services/bl01t-ea-test-01/compose.yml
- services/bl01t-di-cam-01/compose.yml
- services/bl01t-mo-sim-01/compose.yml
- services/gateway/compose.yml
- services/pvagw/compose.yml

Expand Down
15 changes: 11 additions & 4 deletions environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

# This script must be sourced
if [ "$0" = "$BASH_SOURCE" ]; then
echo "ERROR: Please source this script (source environment.sh)"
echo "ERROR: Please source this script (source ./environment.sh)"
exit 1
fi

# if there is a docker-compose module then load it
if [[ $(module avail docker-compose 2>/dev/null) != "" ]] ; then
module load docker-compose
fi

function check_docker {
# return 0 if docker is detected, or 1 otherwise,
# cope with the possibility that podman is aliased to docker
Expand All @@ -22,9 +27,11 @@ function check_docker {
fi
}

# set user id for the phoebus container for easy X11 forwarding.
if check_docker; then
USER_ID=$(id -u); USER_GID=$(id -g)
else
alias docker=podman
USER_ID=0; USER_GID=0
fi

Expand All @@ -35,9 +42,9 @@ xhost +SI:localuser:$(id -un)

# set user id for the phoebus container for easy X11 forwarding.
export UIDGID=$USER_ID:$USER_GID
# choose develop profile for docker compose
export COMPOSE_PROFILES=develop
# for develop profile our ca-gateway publishes PVS on the loopback interface
# choose 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
# make a short alias for docker-compose for convenience
alias ec='docker compose'
3 changes: 2 additions & 1 deletion include/networks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
networks:
channel_access:
name: "channel_access"
ipam:
driver: default
config:
- subnet: "172.20.0.0/16"
- subnet: "172.20.0.0/16"
4 changes: 1 addition & 3 deletions opi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ OPI Files

Hand coded OPI files can be added to this folder for access by phoebus.

The `iocs` folder is reserved for the auto generated engineering screens
that IOCs generate using PVI. The iocs folder is not checked in to git and
changes made there will be lost on IOC restart.
The `auto-generated` folder is reserved for the auto generated engineering screens that IOCs generate using PVI. The auto-generated folder is not checked in to git and changes made there will be lost on IOC restart.
9 changes: 9 additions & 0 deletions opi/auto-generated/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
OPI Files
=========

All files under the opi/auto-generated folder will be generated by PVI at IOC runtime.

These files are not committed to git and any changes made to them will be lost when the related IOC is restarted.

To make custom opi files, create them in the opi root folder or other subfolders of opi.

4 changes: 2 additions & 2 deletions opi/demo.bob
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>iocs/bl01t-di-cam-01/index.bob</file>
<file>auto-generated/bl01t-di-cam-01/index.bob</file>
<macros>
<P>BL01T-EA-TST-01</P>
<R>:DET:</R>
Expand All @@ -461,7 +461,7 @@
<name>OpenDisplay_1</name>
<actions>
<action type="open_display">
<file>iocs/bl01t-mo-sim-01/index.bob</file>
<file>auto-generated/bl01t-mo-sim-01/index.bob</file>
<macros>
<P>BL01T-EA-TST-01</P>
<R>:PVA:</R>
Expand Down
31 changes: 31 additions & 0 deletions services/.ioc_template/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:

replace_me:

extends:
service: linux_ioc
file: ../../include/ioc.yml

image: replace_with_image_uri

labels:
version: 0.1.0

environment:
IOCSH_PS1: replace_me >
IOC_NAME: replace_me

volumes:
- ../../opi/auto-generated/replace_me:/epics/opi

configs:
- source: replace_me_config
target: epics/ioc/config

configs:
replace_me_config:
file: ./config

include:
- path:
../../include/networks.yml
16 changes: 16 additions & 0 deletions services/.ioc_template/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-template-example/releases/download/3.5.1/ibek.ioc.schema.json

# TODO replace above with the generic IOC schema this IOC is based on
ioc_name: "{{ _global.get_env('IOC_NAME') }}"

description: REPLACE WITH DESCRIPTION

entities:
- type: epics.EpicsEnvSet
name: EPICS_TZ
value: GMT0BST

- type: devIocStats.iocAdminSoft
IOC: "{{ ioc_name | upper }}"

# - todo: Add more entities to make a meaningful IOC
2 changes: 1 addition & 1 deletion services/bl01t-di-cam-01/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
IOC_PREFIX: BL01T-DI-CAM-01

volumes:
- ../../opi/iocs/bl01t-di-cam-01:/epics/opi
- ../../opi/auto-generated/bl01t-di-cam-01:/epics/opi

command: /epics/ioc/start.sh

Expand Down
4 changes: 2 additions & 2 deletions services/bl01t-ea-test-01/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
service: linux_ioc
file: ../../include/ioc.yml

image: ghcr.io/epics-containers/ioc-adsimdetector-runtime:2024.6.1
image: ghcr.io/epics-containers/ioc-template-example-runtime:3.5.1

labels:
version: 0.1.0
Expand All @@ -17,7 +17,7 @@ services:
IOC_PREFIX: BL01T-EA-TEST-01

volumes:
- ../../opi/iocs/bl01t-ea-test-01:/epics/opi
- ../../opi/auto-generated/bl01t-ea-test-01:/epics/opi

configs:
- source: bl01t-ea-test-01_config
Expand Down
26 changes: 0 additions & 26 deletions services/bl01t-ea-test-01/config/ioc.db

This file was deleted.

12 changes: 6 additions & 6 deletions services/bl01t-ea-test-01/config/ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ entities:
value: GMT0BST

- type: devIocStats.iocAdminSoft
IOC: '{{ ioc_name | upper }}'
IOC: "{{ ioc_name | upper }}"

- type: epics.StartupCommand
command: dbLoadRecords("/epics/ioc/config/ioc.db")

- type: epics.dbpf
pv: bl01t:IBEK:A
value: '2.54'
pv: bl01t:A
value: "2.54"

- type: epics.dbpf
pv: bl01t:IBEK:B
value: '2.61'
pv: bl01t:B
value: "2.61"

- type: epics.PostStartupCommand
command: |
dbgf bl01t:IBEK:SUM
dbgf bl01t:SUM
31 changes: 31 additions & 0 deletions services/bl01t-mo-sim-01/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:

bl01t-mo-sim-01:

extends:
service: linux_ioc
file: ../../include/ioc.yml

image: ghcr.io/epics-containers/ioc-motorsim-runtime:2024.9.1

labels:
version: 0.1.0

environment:
IOCSH_PS1: bl01t-mo-sim-01 >
IOC_NAME: bl01t-mo-sim-01

volumes:
- ../../opi/auto-generated/bl01t-mo-sim-01:/epics/opi

configs:
- source: bl01t-mo-sim-01_config
target: epics/ioc/config

configs:
bl01t-mo-sim-01_config:
file: ./config

include:
- path:
../../include/networks.yml
33 changes: 33 additions & 0 deletions services/bl01t-mo-sim-01/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-motorsim/releases/download/2024.9.1/ibek.ioc.schema.json

# TODO replace above with the generic IOC schema this IOC is based on
ioc_name: "{{ _global.get_env('IOC_NAME') }}"

description: REPLACE WITH DESCRIPTION

entities:
- type: epics.EpicsEnvSet
name: EPICS_TZ
value: GMT0BST

- type: devIocStats.iocAdminSoft
IOC: "{{ ioc_name | upper }}"

- type: motorSim.simMotorController
controllerName: sim-controller1
numAxes: 2
P: "BL01T-MO-SIMC-01:"

- type: motorSim.simMotorAxis
controller: sim-controller1
ADDR: 0
M: M1
DESC: Motor 1
home: 0

- type: motorSim.simMotorAxis
controller: sim-controller1
ADDR: 1
M: M2
DESC: Motor 2
home: 0
33 changes: 25 additions & 8 deletions services/gateway/compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# When deploying IOCs to a server with docker, the choice is:
#
# 1. Use host network so their PVs available on the subnet
# 2. Run a ca-gateway on each server and add all servers to client's
# EPICS_CA_ADDR_LIST
# 2. Run a ca-gateway on each server
#
# at present the only available option for podman is to use host network
# for local testing we also run a ca-gateway and bind it to localhost

services:

# ca-gateway for development #################################################
# ca-gateway for test / dev ##################################################

ca-gateway: &ca-gateway

container_name: ca-gateway

image: ghcr.io/epics-containers/docker-ca-gateway:2.1.3ec1

expose:
Expand All @@ -27,7 +28,6 @@ services:

networks:
channel_access:
ipv4_address: 172.20.255.254

configs:
- source: ca-gateway_config
Expand All @@ -36,16 +36,29 @@ services:
command: -cip 172.20.255.255 -pvlist /config/pvlist -access /config/access -log /dev/stdout -debug 1

profiles:
- develop
- test
- dev

# debugging version of gateway container #####################################
ca-gateway-debug:

container_name: ca-gateway-debug

<<: *ca-gateway

# this image is not distroless and has network tools installed
image: ghcr.io/epics-containers/docker-ca-gateway-debug:2.1.3ec1

profiles:
- debug

# per server ca-gateway for deployment #######################################
ca-gateway-deploy:

<<: *ca-gateway

ports:
# TODO - drop the IP address but also set up pvlist to make sure there
# are no loops - I need to look into safe config for per server ca-gateways
# 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

Expand All @@ -57,3 +70,7 @@ services:
configs:
ca-gateway_config:
file: ./config

include:
- path:
../../include/networks.yml
Loading

0 comments on commit 18b9b49

Please sign in to comment.