Skip to content

Commit

Permalink
Merge pull request #7 from epics-containers/dev
Browse files Browse the repository at this point in the history
latest ioc-template changes
  • Loading branch information
gilesknap authored Oct 6, 2023
2 parents 0d46a84 + 600570f commit e7d7e28
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 91 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"--net=host",
"--security-opt=label=disable"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/ioc-adaravis,type=bind",
"workspaceFolder": "/epics/ioc-adaravis",
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/epics/${localWorkspaceFolderBasename}",
"mounts": [
// Mount some useful local files from the user's home directory
"source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind",
Expand Down
8 changes: 4 additions & 4 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# the IOC is made at build time but the devcontainer mounts over the top of it
# so we need to regenerate it for devcontainer use

cd /epics/ioc-config
# get the ioc template, generate makefile and compile.
# Commented out because compilation failures stop the devcontainer from starting
# best to let the user do this manually once inside the container

ibek ioc make-source-template
ibek ioc generate-makefile
ibek ioc compile
# ibek ioc compile
9 changes: 5 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# Look for updates to python and docker dependencies.

version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
83 changes: 22 additions & 61 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -1,80 +1,41 @@
#!/bin/bash

# A script for building EPICS container images.
# A generic build script for epics-containers ioc repositories
#
# Note that this is implemented in bash to make it portable between
# CI frameworks. This approach uses the minimum of GitHub Actions.
# Also works locally for testing outside of CI (with podman-docker installed)
# Also works locally for testing outside of CI
#
# INPUTS:
# PUSH: if true, push the container image to the registry
# TAG: the tag to use for the container image
# REGISTRY: the container registry to push to
# REPOSITORY: the container repository to push to
# CACHE: the directory to use for caching
# PLATFORM: the platform to build for (linux/amd64 or linux/arm64)
# CACHE: the directory to use for caching

ARCH=${ARCH:-linux}
PUSH=${PUSH:-false}
if [[ ${PUSH} == 'true' ]] ; then PUSH='--push' ; else PUSH='' ; fi
TAG=${TAG:-latest}
REGISTRY=${REGISTRY:-ghcr.io}

PLATFORM=${PLATFORM:-linux/amd64}
CACHE=${CACHE:-/tmp/ec-cache}
THIS=$(dirname ${0})
set -xe

NEWCACHE=${CACHE}-new

# setup a buildx driver for multi-arch / remote cached builds
docker buildx create --driver docker-container --use

# docker command line parameters
cachefrom=--cache-from=type=local,src=${CACHE}
cacheto=--cache-to=type=local,dest=${NEWCACHE},mode=max

if ! ec --version 2> /dev/null ; then
pip install --upgrade -r ${THIS}/../../requirements.txt
fi

do_build() {
ARCHITECTURE=$1
TARGET=$2
shift 2
# add extra cross compilation platforms below if needed e.g.
# ec dev build --buildx --arch rtems ... for RTEMS cross compile

image_name=${REGISTRY}/${REPOSITORY}-${ARCHITECTURE}-${TARGET}:${TAG}
args="
--build-arg TARGET_ARCHITECTURE=${ARCHITECTURE}
--target ${TARGET}
-t ${image_name}
"
if [[ ${ARCHITECTURE} == "linux" ]] ; then
args="${args} --platform=${PLATFORM}"
fi
# build runtime and developer images
ec --log-level debug dev build --buildx --tag ${TAG} --platform ${PLATFORM} \
--cache-to ${CACHE} --cache-from ${CACHE} ${PUSH}

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

echo "CONTAINER BUILD FOR ${image_name} with ARCHITECTURE=${ARCHITECTURE} ..."

(
set -x
docker buildx build ${args} ${*} .
)
}

# EDIT BELOW FOR YOUR BUILD MATRIX REQUIREMENTS
#
# All builds should use cachefrom and the last should use cacheto
# The last build should execute all stages for the cache to be fully useful.
#
# intermediate builds should use cachefrom but will also see the local cache
#
# If None of the builds use all stages in the Dockerfile then consider adding
# cache-to to more than one build. But note there is a tradeoff in performance
# as every layer will get uploaded to the cache even if it just came out of the
# cache.
# extract the ioc schema from the runtime image
ec dev launch-local --tag ${TAG} --execute \
'ibek ioc generate-schema /epics/links/ibek/*.ibek.support.yaml' \
> ibek.ioc.schema.json

do_build ${ARCH} developer ${cachefrom}
do_build ${ARCH} runtime ${cachefrom} ${cacheto}
# run acceptance tests
shopt -s nullglob # expand to nothing if no tests are found
for t in "${THIS}/../../tests/*.sh"; do bash ${t}; done

docker run --entrypoint bash ${image_name} -c \
'ibek ioc generate-schema /epics/links/ibek/*ibek.support.yaml' > \
ibek.ioc.schema.json
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos*
**/.mypy_cache/

# build pulls the schema out of the container - ignore it
*.ibek.ioc.schema.json
*ibek.ioc.schema.json
# while working on ibek with this project somethimes include it as subfolder
ibek

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
TODO update with correct comment for included support module
An epics-containers generic IOC source file for ADAravis.

A container image template for creating new generic IOCs
Generates a Generic IOC for running in a container and
creating IOC instances to control Aravis cameras.

See the https://epics-containers.github.io

23 changes: 7 additions & 16 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@ TARGET_ARCHITECTURE=${1:-linux}

set -xe

THIS_DIR=$(realpath $(dirname ${0}))
PROJECT=$(basename ${THIS_DIR})
cd $(dirname ${0})

ARGS="
--build-arg TARGET_ARCHITECTURE=${TARGET_ARCHITECTURE}
--build-arg TARGETARCH=amd64
--net host
"

for target in developer runtime ; do
TAG=ghcr.io/epics-containers/${PROJECT}-${TARGET_ARCHITECTURE}-${target}:local
podman buildx build --target ${target} ${ARGS} -t ${TAG} .
done
# build runtime and developer images
ec dev build --arch ${TARGET_ARCHITECTURE}

# get the schema file from the developer container and save it locally
# it is called xxxxx.ioc.ibek.schema.json for project ioc-xxxxx
podman run --entrypoint bash ${TAG} -c \
'ibek ioc generate-schema /epics/links/ibek/*ibek.support.yaml' > \
${PROJECT#ioc-}.ibek.ioc.schema.json
ec dev launch-local --execute \
'ibek ioc generate-schema /epics/links/ibek/*.ibek.support.yaml' \
> ibek.ioc.schema.json

3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
epics-containers-cli==2.2.0
# NOTE: to debug the CLI you can use intermediate builds by looking in Actions and copying the 'dist' URL i.e.
# epics-containers-cli -e https://github.com/epics-containers/epics-containers-cli/suites/16919013647/artifacts/966547589

0 comments on commit e7d7e28

Please sign in to comment.