diff --git a/.github/workflows/buiild.yml b/.github/workflows/buiild.yml index 5a922db..23d861a 100644 --- a/.github/workflows/buiild.yml +++ b/.github/workflows/buiild.yml @@ -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 diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh index e7e90c8..0ab9fd0 100755 --- a/.github/workflows/build.sh +++ b/.github/workflows/build.sh @@ -19,7 +19,7 @@ TAG=${TAG:-latest} REGISTRY=${REGISTRY:-ghcr.io} if [[ -z ${REPOSITORY} ]] ; then # For local builds, infer the registry from git remote (assumes ghcr) - REPOSITORY=$(git remote -v | sed "s/.*@github.com:\(.*\)\.git.*/ghcr.io\/\1/" | tail -1) + REPOSITORY=$(git remote -v | sed "s/.*@github.com:\(.*\) \(.*\)*/\1/" | tail -1) echo "inferred registry ${REPOSITORY}" fi @@ -27,7 +27,7 @@ NEWCACHE=${CACHE}-new if ! docker -v 2> /dev/null; then echo "switching to podman ..." - PODMAN=true + docker=podman shopt -s expand_aliases alias docker=podman @@ -35,6 +35,7 @@ if ! docker -v 2> /dev/null; then cachefrom="" cacheto="" else + docker=docker # setup a buildx driver for multi-arch / remote cached builds docker buildx create --driver docker-container --use # docker command line parameters @@ -58,18 +59,22 @@ do_build() { -t ${image_name} " - if [[ ${PUSH} == "true" && ${PODMAN} != "true" ]] ; then - args="--push "${args} + if [[ $docker != "podman" ]] ; then + if [[ ${PUSH} == "true" ]] ; then + args="--push "${args} + else + args="--load "${args} + fi fi echo "CONTAINER BUILD FOR ${image_name} with ARCHITECTURE=${ARCHITECTURE} ..." ( set -x - docker buildx build ${args} ${*} . + $docker buildx build ${args} ${*} . ) - if [[ ${PUSH} == "true" && ${PODMAN} == "true" ]] ; then + if [[ ${PUSH} == "true" && $docker == "podman" ]] ; then podman push ${image_name} fi } @@ -89,6 +94,19 @@ do_build() { do_build ${ARCH} developer ${cachefrom} do_build ${ARCH} runtime ${cachefrom} ${cacheto} -# remove old cache to avoid indefinite growth -rm -rf ${CACHE} -mv ${NEWCACHE} ${CACHE} + +if [[ $docker != "podman" ]] ; then + # remove old cache to avoid indefinite growth + rm -rf ${CACHE} + mv ${NEWCACHE} ${CACHE} +fi + +# get the schema file from the developer container +echo "Getting schema file from developer container ..." +id=$($docker create ${image_name}) +# 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 +echo "schema file(s): $(ls *.ibek.ioc.schema.json)" diff --git a/.gitignore b/.gitignore index bb84bf7..6ae7439 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .history repos* +# build pulls the schema out of the container - ignore it +*.ibek.ioc.schema.json diff --git a/.gitmodules b/.gitmodules index a68fb7f..1933b7a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ [submodule "ibek-defs"] path = ibek-defs url = git@github.com:epics-containers/ibek-defs.git +[submodule "ibek-support"] + path = ibek-support + url = git@github.com:epics-containers/ibek-support.git diff --git a/Dockerfile b/Dockerfile index d37fcee..1a64bbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,71 +1,41 @@ ##### 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/ADAravis/ ADAravis/ +RUN ADAravis/install.sh R2-3 -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 ################################################ @@ -73,24 +43,21 @@ 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} diff --git a/build b/build index fe29d62..5d7e19b 100755 --- a/build +++ b/build @@ -1,12 +1,9 @@ #!/bin/bash -THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +set -xe -# 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 +THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd ${THIS_DIR} +export TAG=${TAG:-local} -ec dev build --arch linux -#ec dev build --arch rtems +./.github/workflows/build.sh diff --git a/ibek-defs b/ibek-defs deleted file mode 160000 index 3fb7493..0000000 --- a/ibek-defs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3fb74938a2ed9060b57df8b16e3d9f3c3a4aed8f diff --git a/ibek-support b/ibek-support new file mode 160000 index 0000000..2c323eb --- /dev/null +++ b/ibek-support @@ -0,0 +1 @@ +Subproject commit 2c323eb5134946c02622f5f2b9a61eb3886f51a8