Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cross compilation runtime targets with unique base image #25

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
92287db
add example IOC instance and debug launcher
gilesknap Mar 11, 2024
79ce757
add proxy stage
gilesknap Mar 15, 2024
3deca3b
adding rtems startup scripts
gilesknap Mar 15, 2024
f03099b
switch to sh for entrypoint
gilesknap Mar 15, 2024
84586f9
use native aware ibek for runtime stage
gilesknap Mar 16, 2024
c6d0357
update to ibek 1.7.3b3
gilesknap Mar 16, 2024
0cce6ed
use venv in alpine runtime
gilesknap Mar 16, 2024
e9200da
fix entrypoint
gilesknap Mar 16, 2024
310b324
changes for rtems runtime target
gilesknap Mar 16, 2024
618490f
bigger wait on missing ioc.yaml
gilesknap Mar 16, 2024
5ac4db1
use start.sh as main entrypoint for RTEMS iocs
gilesknap Mar 17, 2024
8616c99
update proxy base image
gilesknap Mar 17, 2024
6bf3477
ibek-support better target only builds
gilesknap Mar 17, 2024
bd07d14
fix ioc install.sh
gilesknap Mar 17, 2024
f0734ac
fix start-proxy.sh
gilesknap Mar 17, 2024
596b798
update to new structure of epics-base
gilesknap Mar 18, 2024
05de324
change TARGET_ARCHITECTURE to EPICS_TARGET_ARCH
gilesknap Mar 18, 2024
f8f22a8
dont do parallel developer/runtime builds
gilesknap Mar 19, 2024
408a090
dont call root proxy-start.sh after override
gilesknap Mar 19, 2024
9fe8f7c
update to ibek 1.7.3b1
gilesknap Mar 19, 2024
ae9bd68
switch to new apt-install semantics
gilesknap Mar 19, 2024
84f21ea
add proxy install from pypi
gilesknap Mar 19, 2024
01d1b2e
add proxy to developer stage
gilesknap Mar 19, 2024
40800b4
use epics-base runtime for all targets
gilesknap Mar 19, 2024
431fdf1
ibek 1.8.1b1
gilesknap Mar 19, 2024
4083b03
ibek 1.8.1b2
gilesknap Mar 20, 2024
cd12352
switch to using rtems-proxy python package
gilesknap Mar 20, 2024
42bfe7f
fix arg to rtems-proxy
gilesknap Mar 20, 2024
a2c7faf
rtems-proxy version 0.2.1
gilesknap Mar 20, 2024
9e97788
add proxy debugging facility
gilesknap Mar 20, 2024
401fad9
explicit install of proxy python package
gilesknap Mar 20, 2024
ae533f3
return to using a script for install_proxy
gilesknap Mar 20, 2024
e0ba95c
remove host and target epics arch (they come from base images)
gilesknap Mar 21, 2024
6506d31
update to base 7.0.8ec2b8
gilesknap Mar 21, 2024
1c28016
update to epics base 7.0.8ec2b6
gilesknap Mar 21, 2024
a4628c1
fix build matrix
gilesknap Mar 21, 2024
14a7632
remove ioc/.iocsh_history
gilesknap Mar 21, 2024
fcb9d35
update rtems-proxy 0.2.3
gilesknap Mar 21, 2024
dbce948
update rtems-proxy 0.2.5
gilesknap Mar 21, 2024
38d3c48
updates for RTEMS support
gilesknap Mar 22, 2024
6235f0f
update to latest dependencies
gilesknap Mar 23, 2024
c7c74ab
dont cd in install_proxy
gilesknap Mar 24, 2024
f67a361
fix ioc install.sh
gilesknap Mar 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"name": "epics-containers IOC devcontainer",
"build": {
"dockerfile": "../Dockerfile",
"target": "developer"
"target": "developer",
"args": {
// Native target development settings ==============================
"TARGET_ARCHITECTURE": "linux-x86_64"
gilesknap marked this conversation as resolved.
Show resolved Hide resolved
// Local cross compilation settings ================================
// "TARGET_ARCHITECTURE": "RTEMS-beatnik",
// "RUNTIME": "ghcr.io/epics-containers/rtems-proxy"
}
},
"remoteEnv": {
// allows X11 apps to run inside the container
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@ jobs:
epics-target: [RTEMS-beatnik, linux-x86_64] # , linux-aarch64]
target: [developer, runtime]
include:
- os: ubuntu-latest # everyone is on os-latest

- epics-target: RTEMS-beatnik
epics-host: linux-x86_64
extension: -rtems-beatnik
platform: linux/amd64
os: ubuntu-latest
runtime: "RUNTIME=ghcr.io/epics-containers/rtems-proxy:0.1.6"

- epics-target: linux-x86_64
epics-host: linux-x86_64
extension: ""
platform: linux/amd64
os: ubuntu-latest
runtime: ""

# - epics-target: linux-aarch64
# epics-host: linux-aarch64
# # a temporary name until multi-arch is supported
# extension: -native-aarch64
# platform: linux/arm64
# os: ubuntu-latest

runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -68,14 +69,15 @@ jobs:
TARGET_ARCHITECTURE=${{ matrix.epics-target }}
EPICS_HOST_ARCH=${{ matrix.epics-host }}
IMAGE_EXT=${{ matrix.extension }}
${{ matrix.runtime }}
tags: ${{ env.TAG }}
cache-from: type=gha,scope=${{ matrix.epics-target }}
cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }}
cache-from: type=gha,scope=${{ matrix.epics-target }}-${{ matrix.target }}
cache-to: type=gha,mode=max,scope=${{ matrix.epics-target }}-${{ matrix.target }}
load: true

- name: Test image
# can't test rtems without some hardware to run on
if: contains(${{ matrix.epics-target }}, "RTEMS")
# can't test non native without some hardware to run on
if: ${{ matrix.runtime == '' }}
run: tests/run-tests.sh

- name: Push image
Expand All @@ -89,6 +91,7 @@ jobs:
TARGET_ARCHITECTURE=${{ matrix.epics-target }}
gilesknap marked this conversation as resolved.
Show resolved Hide resolved
EPICS_HOST_ARCH=${{ matrix.epics-host }}
IMAGE_EXT=${{ matrix.extension }}
${{ matrix.runtime }}
tags: ${{ env.TAG }}
push: true

Expand Down
49 changes: 49 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Generic IOC debugging launcher
// To use this l
// 1. make sure you have gdb installed in your container with
// apt update; apt-get install gdb
// 2. run the IOC once to make sure rutime assets are generated:
// cd /epics/ioc; make
// ./start.sh
// 3. stop the IOC with 'exit'
// 4. In vscode go to the support source in /epics/support/xxx
// 5. Set any breakpoints in the source code that you require.
// 6. You may want to set 'HOST_OPT=NO' in CONFIG_SITE and rebuild the support
// 6. Go to the debug tab and select 'IOC devcontainer debug' from the
// RUN AND DEBUG dropdown
{
"version": "0.2.0",
"configurations": [
{
"name": "IOC devcontainer debug",
"type": "cppdbg",
"request": "launch",
"program": "/epics/ioc/bin/linux-x86_64/ioc",
"args": [
"/epics/runtime/st.cmd"
],
"stopAtEntry": false,
"cwd": "/epics/ioc",
"environment": [
{
"name": "RUNTIME_DIR",
"value": "/epics/runtime"
}
],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
##### build stage ##############################################################

ARG TARGET_ARCHITECTURE=linux-x86_64
ARG EPICS_HOST_ARCH=linux-x86_64
ARG IMAGE_EXT

ARG BASE=7.0.8ec2b1
ARG REGISTRY=ghcr.io/epics-containers
ARG RUNTIME=${REGISTRY}/epics-base${IMAGE_EXT}-runtime:${BASE}

##### build stage ##############################################################
FROM ${REGISTRY}/epics-base${IMAGE_EXT}-developer:${BASE} AS developer

gilesknap marked this conversation as resolved.
Show resolved Hide resolved
# The devcontainer mounts the project root to /epics/generic-source
Expand Down Expand Up @@ -56,22 +56,19 @@ COPY ioc ${SOURCE_FOLDER}/ioc
RUN cd ${IOC} && ./install.sh && make

##### runtime preparation stage ################################################

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
RUN ibek ioc extract-runtime-assets /assets ${SOURCE_FOLDER}/ibek*

##### runtime stage ############################################################

FROM ${REGISTRY}/epics-base${IMAGE_EXT}-runtime:${BASE} AS runtime
FROM ${RUNTIME} AS runtime

# get runtime assets from the preparation stage
COPY --from=runtime_prep /assets /

# install runtime system dependencies, collected from install.sh scripts
RUN ibek support apt-install --runtime

gilesknap marked this conversation as resolved.
Show resolved Hide resolved
ENV TARGET_ARCHITECTURE ${IMAGE_NAME}
ENTRYPOINT ["bash", "-c", "${IOC}/start.sh"]

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
12 changes: 8 additions & 4 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
# generic local build script for epics-containers repositories #
################################################################################

# log commands and stop on errors
set -xe
set -e

# set TARGET_ARCHITECTURE to rtems for RTEMS based targets
T_A=${TARGET_ARCHITECTURE:-linux_x86_64}
# set TARGET to runtime for runtime images
TARGET=${TARGET:-developer}
# set TAG to override the default tag
TAG=${TAG:-ec_test}

if [[ ${T_A} != "linux_x86_64" ]]; then
# container image extension is the lcase of TARGET_ARCHITECTURE
IMAGE_EXT=-"${T_A,,}"
if [ "$T_A" = "RTEMS-beatnik" ]; then
runtime="--build-arg RUNTIME=ghcr.io/epics-containers/rtems-proxy"
fi
fi

cd $(dirname ${0})
Expand All @@ -28,7 +31,8 @@ if $docker buildx version &>/dev/null; then builx=buildx; load=--load; fi
if [ ! -d ibek-support ] ; then git submodule update --init ; fi

# build and developer images
$docker build $buildx -t ${TAG} "${@}" $load \
set -x
$docker build $buildx -t ${TAG} "${@}" $load \
--build-arg TARGET_ARCHITECTURE=$T_A \
--build-arg IMAGE_EXT=$IMAGE_EXT \
--target $TARGET .
$runtime --target $TARGET .
2 changes: 1 addition & 1 deletion ioc/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
x86_cfg='./configure/CONFIG_SITE.Common.linux-x86_64'

# for RTEMS builds don't build for the host architecture, target only
if [[ $TARGET_ARCHITECTURE == "rtems" ]]; then
if [[ $TARGET_ARCHITECTURE == "RTEMS"* ]]; then
touch ${x86_cfg}
sed -i '/VALID_BUILDS/d' ${x86_cfg}
echo "VALID_BUILDS=Host" >> ${x86_cfg}
Expand Down
18 changes: 11 additions & 7 deletions ioc/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ description='
4. empty config folder *******************************************************
If the config folder is empty this message will be displayed.


RTEMS IOCS - RTEMS IOC startup files can be generated using any of the above.

For RTEMS we do not execute the ioc inside of the pod. Instead we:
Expand All @@ -74,7 +73,7 @@ function ibek_error {
echo "${1}"

# Wait for a bit so the container does not exit and restart continually
sleep 10
sleep 120
}

# environment setup ************************************************************
Expand Down Expand Up @@ -156,12 +155,17 @@ fi

# Launch the IOC ***************************************************************

if [[ ${TARGET_ARCHITECTURE} == "rtems" ]] ; then
echo "RTEMS IOC startup - copying IOC to RTEMS mount point ..."
cp -r ${IOC} ${K8S_IOC_ROOT}
sleep 100
else
if [[ ${TARGET_ARCHITECTURE} == "linux-x86_64" ]] ; then
gilesknap marked this conversation as resolved.
Show resolved Hide resolved
# Execute the IOC binary and pass the startup script as an argument
exec ${IOC}/bin/linux-x86_64/ioc ${final_ioc_startup}
else
# not native architectures will have a proxy-start.sh in the root
if [[ -f ${CONFIG_DIR}/proxy-start.sh ]]; then
# instances can provide their own proxy-start ovedrride in config
bash ${CONFIG_DIR}/proxy-start.sh
fi
# the proxy container will provide a default proxy-start.sh in the root
bash /proxy-start.sh
gilesknap marked this conversation as resolved.
Show resolved Hide resolved
fi


2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ibek==1.7.0
ibek==1.7.2b6
# to install direct from github during development in a branch
# git+https://github.com/epics-containers/ibek.git@fix-extract-assets
71 changes: 71 additions & 0 deletions services/bl01t-mo-ioc-01/config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# yaml-language-server: $schema=https://github.com/epics-containers/ioc-pmac/releases/download/2024.1.2/ibek.ioc.schema.json
ioc_name: bl01t-mo-ioc-01

description: |
Test IOC instance for pmac generic IOC.
Connects to the test pmac clipper under giles' desk

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

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

- type: pmac.pmacAsynIPPort
IP: 172.23.240.97:1025
name: BRICK1port

- type: pmac.GeoBrick
IdlePoll: 1000
NAXES: 4
P: BL47P-MO-BRICK-01
name: BRICK1
pmacAsynPort: BRICK1port

- type: pmac.dls_pmac_asyn_motor
is_cs: false
ACCL: 0.1
ADDR: 1
Controller: BRICK1
DESC: Motor 1
DHLM: 25
DLLM: -25
EGU: mm
M: :MOTOR1
MRES: -0.01
P: BL01T-MO-BRICK-01
VELO: 4

- type: pmac.dls_pmac_asyn_motor
is_cs: false
ACCL: 0.1
ADDR: 2
Controller: BRICK1
DESC: Motor 1
DHLM: 25
DLLM: -25
EGU: mm
M: :MOTOR2
MRES: -0.01
P: BL01T-MO-BRICK-01
VELO: 4

# test clipper has 3 coordinate systems configured and pmac will segfault at
# present if these are not configured.
- type: pmac.CS
CS: 1
IdlePoll: 1000
PmacController: BRICK1
name: CS2
- type: pmac.CS
CS: 2
IdlePoll: 1000
PmacController: BRICK1
name: CS1
- type: pmac.CS
CS: 3
IdlePoll: 1000
PmacController: BRICK1
name: CS3
Loading