Skip to content

Commit

Permalink
add ioc schema publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Sep 27, 2023
1 parent b4980fc commit d868d97
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 70 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/buiild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,32 @@ jobs:
PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
CACHE: ${{ env.CACHE }}
run: .github/workflows/build.sh

- name: Upload schema as artifact
uses: actions/upload-artifact@v3
with:
name: ioc-schema
path: ./*.ibek.ioc.schema.json

release:
# Release on tag push - publish ioc schema
needs: [build-push-images]
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
name: ioc-schema
path: ./
zip: false

- name: Github Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: |
./*.ibek.ioc.schema.json
generate_release_notes: true
17 changes: 15 additions & 2 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ do_build() {
-t ${image_name}
"

if [[ ${PUSH} == "true" && ${PODMAN} != "true" ]] ; then
args="--push "${args}
if [[ ${PODMAN} != "true" ]] ; then
if [[ ${PUSH} == "true" ]] ; then
args="--push "${args}
else:
args="--load "${args}
fi
fi

echo "CONTAINER BUILD FOR ${image_name} with ARCHITECTURE=${ARCHITECTURE} ..."
Expand Down Expand Up @@ -92,3 +96,12 @@ do_build ${ARCH} runtime ${cachefrom} ${cacheto}
# remove old cache to avoid indefinite growth
rm -rf ${CACHE}
mv ${NEWCACHE} ${CACHE}

# get the schema file from the developer container
id=$(docker create ${REGISTRY}/${REPOSITORY}-${ARCH}-developer:${TAG})
# convention for schema name is module.ibek.ioc.schema.json
# we get this my removing the ioc- prefix from the module name
SCHEMA=$(basename ${REPOSITORY} | sed 's/^ioc-//').ibek.ioc.schema.json
docker cp $id:/epics/ioc/${SCHEMA} .
docker rm -v $id

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.history
repos*
# build pulls the schema out of the container - ignore it
*.ibek.ioc.schema.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
[submodule "ibek-defs"]
path = ibek-defs
url = [email protected]:epics-containers/ibek-defs.git
[submodule "ibek-support"]
path = ibek-support
url = [email protected]:epics-containers/ibek-support.git
101 changes: 34 additions & 67 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,96 +1,63 @@
##### build stage ##############################################################

ARG TARGET_ARCHITECTURE
ARG BASE=23.3.1

FROM ghcr.io/epics-containers/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
libboost-all-dev \
libxext-dev \
libglib2.0-dev \
libusb-1.0 \
libxml2-dev \
libx11-dev \
meson \
intltool \
pkg-config \
xz-utils

# build aravis library
RUN cd /usr/local && \
git clone -b ARAVIS_0_8_1 --depth 1 https://github.com/AravisProject/aravis && \
cd aravis && \
meson build && \
cd build && \
ninja && \
ninja install && \
rm -fr /usr/local/aravis \
echo /usr/local/lib64 > /etc/ld.so.conf.d/usr.conf && \
ldconfig

COPY ctools /ctools/
RUN pip install ibek==0.9.5.b2 telnetlib3
ARG BASE=7.0.7ec1
ARG REGISTRY=ghcr.io/epics-containers

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

# In a devcontainer this folder is mounted on the host's clone of ioc-adsimdetector
WORKDIR /workspaces/ioc-adsimdetector/ibek-support

# copy the global ibek files
COPY ibek-defs/_global /ctools/_global/
COPY ibek-support/_global/ _global

COPY ibek-defs/asyn/ /ctools/asyn/
RUN python3 modules.py install ASYN R4-42 github.com/epics-modules/asyn.git --patch asyn/asyn.sh
RUN make -C ${SUPPORT}/asyn -j $(nproc)
COPY ibek-support/iocStats/ iocStats
RUN iocStats/install.sh 3.1.16

COPY ibek-defs/autosave/ /ctools/autosave/
RUN python3 modules.py install AUTOSAVE R5-10-2 github.com/epics-modules/autosave.git --patch autosave/autosave.sh
RUN make -C ${SUPPORT}/autosave -j $(nproc)
COPY ibek-support/asyn/ asyn/
RUN asyn/install.sh R4-42

COPY ibek-defs/busy/ /ctools/busy
RUN python3 modules.py install BUSY R1-7-3 github.com/epics-modules/busy.git
RUN make -C ${SUPPORT}/busy -j $(nproc)
COPY ibek-support/autosave/ autosave/
RUN autosave/install.sh R5-10-2

COPY ibek-defs/adsupport/ /ctools/adsupport/
RUN python3 modules.py install ADSUPPORT R1-10 github.com/areaDetector/adsupport.git --patch adsupport/adsupport.sh
RUN make -C ${SUPPORT}/adsupport -j $(nproc)
COPY ibek-support/busy/ busy/
RUN busy/install.sh R1-7-3

COPY ibek-defs/adcore/ /ctools/adcore/
RUN python3 modules.py install ADCORE R3-12-1 github.com/areaDetector/adcore.git --patch adcore/adcore.sh
RUN make -C ${SUPPORT}/adcore -j $(nproc)
COPY ibek-support/ADCore/ ADCore/
RUN ADCore/install.sh R3-12-1

COPY ibek-defs/adaravis/ /ctools/adaravis/
RUN python3 modules.py install ADGENICAM R1-8 github.com/areaDetector/adgenicam.git --patch adaravis/adaravis.sh
RUN make -C ${SUPPORT}/adgenicam -j $(nproc)
COPY ibek-support/ADSimDetector/ ADSimDetector/
RUN ADSimDetector/install.sh R2-10

RUN python3 modules.py install ADARAVIS R2-2-1 github.com/areaDetector/adaravis.git --patch adaravis/adaravis.sh
RUN make -C ${SUPPORT}/adaravis -j $(nproc)
# Make the IOC
RUN ibek ioc generate-makefile
RUN ibek ioc compile

# add the generic IOC source code. TODO: this will be generated by ibek in future
COPY ioc ${IOC}
# build generic IOC
RUN make -C ${IOC} && make clean -C ${IOC}
# create a schema file for the IOC
RUN bash -c "ibek ioc generate-schema */*ibek.support.yaml --output ${IOC}/adaravis.ibek.ioc.schema.json"

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

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
WORKDIR /min_files
RUN bash /ctools/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/) /ctools
RUN bash /epics/scripts/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/)

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

FROM ghcr.io/epics-containers/epics-base-${TARGET_ARCHITECTURE}-runtime:${BASE} AS runtime

RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
libglib2.0-bin \
libusb-1.0 \
libxml2 \
&& rm -rf /var/lib/apt/lists/*
FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-runtime:${BASE} AS runtime

# get the virtual environment from the developer stage
COPY --from=developer /venv /venv
# add products from build stage
COPY --from=runtime_prep /min_files /
COPY --from=developer /venv /venv

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

# add ioc sample startup scripts
COPY ioc ${IOC}

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}
Expand Down
10 changes: 10 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/bin/bash

set -xe

THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

ioc_name=$(basename ${THIS_DIR})
# schema name drops the ioc- prefix
schema_prefix=${ioc_name##*-}

# a script to locally build all targets containers for this IOC
# Note this requires the ec command form
# https://github.com/epics-containers/epics-containers-cli
Expand All @@ -10,3 +16,7 @@ cd ${THIS_DIR}

ec dev build --arch linux
#ec dev build --arch rtems

id=$(podman create ghcr.io/epics-containers/${ioc_name}-linux-developer:local)
podman cp $id:/epics/ioc/${schema_prefix}.ibek.ioc.schema.json .
podman rm -v $id
1 change: 0 additions & 1 deletion ibek-defs
Submodule ibek-defs deleted from 3fb749
1 change: 1 addition & 0 deletions ibek-support
Submodule ibek-support added at 2c323e

0 comments on commit d868d97

Please sign in to comment.