Skip to content

Commit

Permalink
Merge pull request #28 from epics-containers/update-to-latest-template
Browse files Browse the repository at this point in the history
Update to latest template
  • Loading branch information
gilesknap authored Jan 28, 2024
2 parents 4119065 + cfc1213 commit 4d7459c
Show file tree
Hide file tree
Showing 35 changed files with 533 additions and 208 deletions.
25 changes: 14 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"features": {
// add quality of life features for developers including git config integration
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": false,
"installOhMyZsh": false,
"installOhMyZshConfig": false,
// don't upgrade to make this similar to the runtime container
"upgradePackages": false
}
},
// IMPORTANT for this devcontainer to work with docker EC_REMOTE_USER must be
// set to vscode. For podman it should be left blank.
// set to vscode. You will run as vscode with full sudo rights.
// For podman it should be left blank. You will run as root but host mounts
// will be owned by your user.
"remoteUser": "${localEnv:EC_REMOTE_USER}",
"customizations": {
"vscode": {
Expand All @@ -34,7 +35,7 @@
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"epicsdeb.vscode-epics",
"ms-python.black-formatter"
"charliermarsh.ruff"
]
}
},
Expand All @@ -47,15 +48,17 @@
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
// Make sure SELinux does not disable with access to host filesystems like tmp
// Make sure SELinux does not disable write access to host filesystems like tmp
"--security-opt=label=disable"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/epics/${localWorkspaceFolderBasename}",
// Mount the parent of the project folder so we can access peer projects
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
// mount in other useful files from the host
"mounts": [
// Mount some useful local files from the user's home directory
// By mounting the parent of the workspace we can work on multiple peer projects
"source=${localWorkspaceFolder}/../,target=/repos,type=bind",
// we also mount the project folder into a know location in the container
// this is where the ibek-support and ioc folders reside in the container build
// in this way the devcontainer and runtime look very similar
"source=${localWorkspaceFolder},target=/epics/generic-source,type=bind",
// this provides eternal bash history in and out of the container
"source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind",
// this bashrc hooks up the .bashrc_dev_container in the following mount
Expand Down
5 changes: 2 additions & 3 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

if [[ $USER != "root" ]] ; then
# make sure the non-root user can build iocs and (mounted in) support modules
sudo chown -R ${USER}:${USER} /epics/links /venv
sudo chown -h ${USER}:${USER} /epics /epics/ioc
sudo chown -R ${USER}:${USER} /epics/ibek-defs /epics/pvi-defs /epics/support/configure /venv
sudo chown -h ${USER}:${USER} /epics /epics/ioc /epics/support

# also give non-root user access to the same bash config we use in podman
sudo chmod a+rx /root
Expand All @@ -23,7 +23,6 @@ fi
# all epics-containers devcontainers
################################################################################


# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
. ~/.bashprofile_dev_container
Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/build.sh

This file was deleted.

72 changes: 39 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,69 +11,75 @@ jobs:
permissions:
contents: read
packages: write
env:
CACHE: /tmp/.buildx-cache
strategy:
fail-fast: false
max-parallel: 1 # take advantage of caching
matrix:
target: [developer, runtime]
architecture: [linux]
include:
- architecture: linux
os: ubuntu-latest
platform: linux/amd64
- os: ubuntu-latest
platforms: linux/amd64

runs-on: ${{ matrix.os }}
env:
TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.architecture }}-${{ matrix.target }}:${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: ${{ env.CACHE }}
key: ${{ runner.os }}-${{ matrix.architecture }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.architecture }}-buildx-
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io/${{ github.repository_owner }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup python
uses: actions/setup-python@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
uses: docker/build-push-action@v5
with:
python-version: "3.10"
context: .
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Docker Build Script
env:
ARCH: ${{ matrix.architecture }}
PLATFORM: ${{ matrix.platform }}
TAG: ${{ github.ref_name }}
PUSH: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
CACHE: ${{ env.CACHE }}
run: .github/workflows/build.sh
- name: Test image
run: tests/run-tests.sh

- name: Upload schema as artifact
uses: actions/upload-artifact@v3
- name: Push image
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/build-push-action@v5
with:
name: ioc-schema
path: ibek.ioc.schema.json
context: .
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
push: true

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

# this job runs in the (linux) developer container we just made
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-linux-developer:${{ github.ref_name }}

steps:
- uses: actions/download-artifact@v3
with:
name: ioc-schema
path: ./
- name: generate-schema
run: |
ibek ioc generate-schema --output ibek.ioc.schema.json
- name: Github Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
Expand Down
11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ repos*
# while working on ibek with this project somethimes include it as subfolder
ibek

# The ioc source tree is created here from a template inside the generic ioc
# repo.
# Remove from .gitignore if you want to customize the template.
/ioc/

# dont save workspaces as other users will have differing folders
*workspace

# config folder is there to be replaced there is just a dummy with Readme.
ioc/config

# opi folder is created to hold generated operator interface files
/opi/
# podman may leave this around in aborted builds
.build.swp
19 changes: 12 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
##### build stage ##############################################################

ARG TARGET_ARCHITECTURE
ARG BASE=7.0.7ec2
ARG BASE=7.0.7ec3
ARG REGISTRY=ghcr.io/epics-containers

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

# The devcontainer mounts the project root to /epics/generic-source
# Using the same location here makes devcontainer/runtime differences transparent.
ENV SOURCE_FOLDER=/epics/generic-source
# connect ioc source folder to its know location
RUN ln -s ${SOURCE_FOLDER}/ioc ${IOC}

# Get latest ibek while in development. Will come from epics-base when stable
COPY requirements.txt requirements.txt
RUN pip install --upgrade -r requirements.txt

# The devcontainer mounts the project root to /epics/ioc-adsimdetector. Using
# the same location here makes devcontainer/runtime differences transparent.
WORKDIR /epics/ioc-adaravis/ibek-support
WORKDIR ${SOURCE_FOLDER}/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global
Expand Down Expand Up @@ -44,15 +48,16 @@ RUN ADGenICam/install.sh R1-9
COPY ibek-support/ADAravis/ ADAravis/
RUN ADAravis/install.sh R2-3

# create IOC source tree, generate Makefile and compile IOC Instance
RUN ibek ioc build
# get the ioc source and build it
COPY ioc ${SOURCE_FOLDER}/ioc
RUN cd ${IOC} && 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 --extras /usr/local/lib/x86_64-linux-gnu
RUN ibek ioc extract-runtime-assets /assets ${SOURCE_FOLDER}/ibek* /usr/local/lib/x86_64-linux-gnu

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

Expand Down
18 changes: 12 additions & 6 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
# generic local build script for epics-containers ioc repositories #
################################################################################

# pass rtems as first argument to build RTEMS on cross-compiler
TARGET_ARCHITECTURE=${1:-linux}
# set TARGET_ARCHITECTURE to rtems for RTEMS based targets
T_A=${TARGET_ARCHITECTURE:-linux}
# set TARGET to runtime for runtime images
TARGET=${TARGET:-developer}
# set TAG to override the default tag
TAG=${TAG:-ec_test}

# log commands and stop on erros
set -xe

cd $(dirname ${0})

# use docker if available else use podman
if ! docker version &>/dev/null; then alias docker=podman; fi

# make sure new repos get their submodule ibek-support
git submodule update --init

# build runtime and developer images
ec dev build --arch ${TARGET_ARCHITECTURE}
# build and developer images
docker build -t ${TAG} --build-arg TARGET_ARCHITECTURE=$T_A --target $TARGET .

# get the schema file from the developer container and save it locally
ec dev launch-local --execute 'ibek ioc generate-schema' > ibek.ioc.schema.json
2 changes: 1 addition & 1 deletion ibek-support
Submodule ibek-support updated 39 files
+2 −1 ADAravis/install.sh
+122 −0 ADCore-slim/ADCore.ibek.support.yaml
+300 −0 ADCore-slim/ADDriver.pvi.device.yaml
+176 −0 ADCore-slim/NDPluginDriver.pvi.device.yaml
+4 −0 ADCore-slim/NDPluginFile.pvi.device.yaml
+14 −0 ADCore-slim/NDPluginPva.pvi.device.yaml
+273 −0 ADCore-slim/asynNDArrayDriver.pvi.device.yaml
+63 −0 ADCore-slim/install.sh
+1 −197 ADCore/asynNDArrayDriver.pvi.device.yaml
+2 −1 ADCore/install.sh
+2 −1 ADGenICam/install.sh
+64 −0 ADSample/ADSimDetector.ibek.support.yaml
+27 −0 ADSample/install.sh
+297 −0 ADSample/simDetector.pvi.device.yaml
+5 −0 ADSimDetector/ADSimDetector.ibek.support.yaml
+2 −1 ADSimDetector/install.sh
+293 −295 ADSimDetector/simDetector.pvi.device.yaml
+35 −0 StreamDevice/install.sh
+1 −1 _global/epics.ibek.support.yaml
+27 −119 asyn/asyn.ibek.support.yaml
+3 −2 asyn/install.sh
+2 −1 autosave/install.sh
+6 −1 busy/install.sh
+3 −2 calc/install.sh
+5 −1 iocStats/install.sh
+33 −0 lakeshore340/install.sh
+68 −0 lakeshore340/lakeshore340.ibek.support.yaml
+83 −0 modbus/README.md
+38 −0 modbus/install.sh
+272 −0 modbus/modbus.ibek.support.yaml
+3 −3 motor/install.sh
+48 −61 motor/motor.ibek.support.yaml
+28 −0 motorMotorSim/install.sh
+123 −0 motorMotorSim/motorMotorSim.ibek.support.yaml
+67 −0 opcua/install.sh
+2 −1 pmac/install.sh
+2,243 −0 pmac/pmac.ibek.support.todo
+420 −2,988 pmac/pmac.ibek.support.yaml
+2 −1 sscan/install.sh
10 changes: 10 additions & 0 deletions ioc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*~
O.*
bin
dbd
db
data
lib
.svn*
iocs/*IOC*
.idea
7 changes: 7 additions & 0 deletions ioc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TOP = .
include $(TOP)/configure/CONFIG

DIRS += configure
DIRS += iocApp/src

include $(TOP)/configure/RULES_TOP
30 changes: 30 additions & 0 deletions ioc/configure/CONFIG
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CONFIG - Load build configuration data
#
# Do not make changes to this file!

# Allow user to override where the build rules come from
RULES = $(EPICS_BASE)

# RELEASE files point to other application tops
include $(TOP)/configure/RELEASE
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/RELEASE.Common.$(T_A)
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
endif

CONFIG = $(RULES)/configure
include $(CONFIG)/CONFIG
-include $(CONFIG)/CONFIG.Dls

# Override the Base definition:
INSTALL_LOCATION = $(TOP)

# CONFIG_SITE files contain other build configuration settings
include $(TOP)/configure/CONFIG_SITE
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
ifdef T_A
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
endif

5 changes: 5 additions & 0 deletions ioc/configure/CONFIG_SITE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CONFIG_SITE

CROSS_COMPILER_TARGET_ARCHS =
CHECK_RELEASE = NO

8 changes: 8 additions & 0 deletions ioc/configure/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
TOP=..

include $(TOP)/configure/CONFIG

TARGETS = $(CONFIG_TARGETS)
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))

include $(TOP)/configure/RULES
5 changes: 5 additions & 0 deletions ioc/configure/RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The following definitions must be changed for each site
#
# Common prefixes
SUPPORT=/epics/support
include $(SUPPORT)/configure/RELEASE
Loading

0 comments on commit 4d7459c

Please sign in to comment.