CLI reference#
Use ibek --help and ibek <group> <command> --help for the installed
version. The complete command reference below is generated from the CLI.
When to run each command#
Phase |
Commands |
Purpose |
|---|---|---|
Container build |
|
Describe support YAML and install declared runtime Debian packages. |
Container build |
|
Install runtime patterns beside the image’s support modules, and verify them. |
Container build |
|
Describe the image’s available entities and package its runtime files. |
Container startup |
|
Generate the instance, place its files, prepare autosave, and wait for hardware. |
Container build |
|
Record the source tree the image is built from. |
Development container |
|
Compare the container with the mounted project and bring it level. |
Development container |
|
Build support modules from clones on the host, to work on their source. |
Development container |
|
Select a checked-out instance; experimentally execute Dockerfile steps. |
Outside the IOC container |
|
Maintain runtime support and editor schemas in an instance repository. |
These are intended environments, not enforced modes. Schema generation can also
run outside a container with explicit input paths. Compiling EPICS modules is
handled by the build recipes in ibek-support,
not by a general-purpose ibek build command.
Runtime generation#
In an IOC image, the startup script normally runs the equivalent of:
ibek runtime generate2 /epics/ioc/config
ibek runtime place-files /epics/ioc/config
ibek runtime generate-autosave
ibek ioc do-wait
generate2 reads ioc.yaml then runtime.yaml when present in the supplied
folder. Repeated --instance / -i options add files before those two;
the first file supplies the IOC name and later files append entities and
post_db_files entries. Without
--definitions, support definitions are discovered recursively in
$EPICS_ROOT/ibek-defs and the config folder. Supplying --definitions replaces
that automatic discovery; repeat it for each required file. A module defined in
both places is reported with a warning: the config folder’s entity models
replace the image’s of the same name.
Generation recreates the output directory (default /epics/runtime), writing
st.cmd, ioc.subst, and any generated auxiliary files. Run place-files
after generation: it copies top-level .proto / .protocol files into
runtime/protocol, and .db / .template files into runtime/db.
PVI generation is enabled by default; --no-pvi disables it. --output changes
the startup/substitution output directory, but does not relocate every runtime
or PVI path. See Paths and environment.
The image’s startup script still expands substitutions with EPICS msi and
launches the IOC executable. generate2 does not start the IOC.
runtime generate remains available for legacy single-file invocations; use
generate2 for new scripts.
Schema generation#
The three schema commands have different inputs:
# The format accepted by every *.ibek.support.yaml file
ibek support generate-schema --output ibek.support.schema.json
# IOC entities supplied by explicitly named support definitions
ibek ioc generate-schema --no-ibek-defs motor.ibek.support.yaml \
--output ibek.ioc.schema.json
# Published image entities plus an instance's local runtime support
ibek pattern schema services/my-ioc
The first two print JSON to stdout when --output is omitted.
ioc generate-schema includes definitions directly in /epics/ibek-defs by
default; --no-ibek-defs disables that lookup. pattern schema instead uses
the published schema for the instance’s image; see
Vendor runtime support and Paths and environment for
its cache behavior.
Development commands#
ibek dev instance /workspaces/my-services/services/my-ioc
This replaces /epics/ioc/config with a symlink to the instance’s config
directory. It removes the previous directory or link, so use it in the
development container with the instance configuration kept in version control.
A container from a pre-built image#
A devcontainer mounts the host project over /epics/generic-source, the
folder the image was built from. The host’s checkout can differ from the
image’s copy, so the last step of the Dockerfile’s developer stage records
what was built:
COPY Dockerfile requirements.txt ${SOURCE_FOLDER}/
RUN ibek dev stamp
dev stamp writes /epics/dev-stamp.json: hashes of the Dockerfile’s ARG
and FROM lines, requirements.txt, ibek-support/_ansible (without its
vars folder), and for each RUN ansible.sh <module> line the module’s
folder in ibek-support*, split into its definition files
(*.ibek.support.yaml, *.pvi.device.yaml, *.req) and the rest. A third
hash per module covers what its install.yml says to clone: module,
version, organization, git_repo, recursive, patch_file and the
content of the patch, with any -v <version> of the module’s Dockerfile line.
The stamp also holds the rest of that line: what comes before the module name
and what comes after it. The hashes cover file names and content, with CRLF read
as LF. They leave out file modes and a fixed list of names: .git,
.ansible, __pycache__, *.pyc, *build.log, *~, *.swp and
.DS_Store. Any other file in a hashed folder counts, tracked by git or not.
A symbolic link counts as its link text, not as what it points at.
The stamp does not cover the files that ibek pattern install writes into the
image: they are not compared, and dev sync leaves them as they are.
ibek dev status # show the differences, change nothing
ibek dev sync # fix what needs no build, report the rest
ibek dev sync --build # also rebuild what is out of date
Difference |
|
|
|---|---|---|
A module’s definition files |
Runs |
The same. |
A module’s other files, the module list, |
Reported. |
Runs |
|
Reported. |
Runs |
The base image |
Reported: pull a newer developer image or rebuild it locally. |
The same. |
The IOC binary is missing, older than |
Reported: run |
Runs |
A module is built from the source already in /epics/support/<module>, or
in the folder that a local_path in its install.yml names,
unless what its install.yml says to clone, or the -v of its Dockerfile
line, has changed. Then
ansible.sh <module> --tags clone -e force_clone=true first removes that
folder and clones it again: edits made in the folder are discarded. A
folder that is a symbolic link is never removed: the module is built in it
as it is. Both
dev status and dev sync name each folder that dev sync --build would
remove. The new clone is recorded before the build, so if the build fails,
the next dev sync --build builds the folder as it then is, without cloning
again. A module with no folder in /epics/support is cloned the same way,
with ansible.sh <module> --tags clone, before its build. If a clone fails,
the folder may hold some other source, such as the repository’s default
branch, which the clone tasks keep: until a clone succeeds, dev status
reports clone not finished and each dev sync --build clones the module
again, at whatever version its install.yml and Dockerfile line then give. A module declared with dev support is linked to its clone instead, and a link is built as it is. A
module the Dockerfile no longer builds stays installed, and reported, until
the container is recreated from an image built without it.
dev sync --build builds a module with its own line of the Dockerfile:
RUN ansible.sh -v R2 motor -e skip_clean=true is run again as
ansible.sh -v R2 motor -e skip_clean=true, and a change to the line counts
as a change to the module. The two commands that ibek issues with tags of its
own keep the line’s -v and its arguments other than --tags and
--skip-tags, after ibek’s: ansible.sh -v R2 motor --tags runtime -e skip_clean=true. A line whose tags leave out runtime, such as
RUN ansible.sh vdct --tags system,pre_build_tasks, links no definition
files, so dev sync links none for it. A line whose tags leave out clone
is never cloned again: a change to what its install.yml says to clone runs
the line again, as a change to the line’s -v does. A line that is more than one ansible.sh command (&&, ;,
a pipe, a redirect, a variable, a continuation \), or that has an option
before the module other than -v, cannot be run again as it stands: dev stamp and dev sync --build stop with one line that names it, and dev status and dev sync report it.
The IOC line goes when the IOC binary is newer than each of the files and
the build it is compared with, as it is once make has built it.
dev sync exits 0 when it only has differences to report; a command it runs
that fails gives its exit code. The stamp records each module as it is built,
so after a failed build the next dev sync --build starts at the module that
failed. In an image with no stamp, each of these commands says so in one line
and exits 0. A stamp that cannot be read, a missing Dockerfile or
requirements.txt, an ibek-support submodule that is not checked out, and
a module folder that cannot be read are one line too: dev status and dev sync
exit 0, dev sync --build exits 1. dev instance prints the same
report after linking the instance.
A container keeps the image it was created from: “Reopen in Container” in
VS Code uses the existing container even when the host has pulled or built
a different developer image, usually a later one. The devcontainer’s
start-up script on the host writes the ID of the image its tag points to
into .devcontainer/image-id in the project, which the container sees as
/epics/generic-source/.devcontainer/image-id. When a container is created,
its postCreateCommand copies that file to /epics/dev-image-id. When both
files can be read and name different images (a sha256: prefix and
surrounding white space apart), dev status and dev sync start their
report with a line that begins WARNING: and says to use “Dev Containers:
Rebuild Container”. dev instance prints it after its Symlinking line.
dev sync --build prints it again as its last line when it has rebuilt
anything or upgraded the Python packages, since a build prints enough to
push the first one out of sight. With either file missing, empty or
unreadable (a file that is not text counts as unreadable), nothing is said.
The warning changes no exit code and nothing that the commands do, and it
does not need a stamp.
ioc build-docker is experimental: it interprets supported Dockerfile steps
inside the development container; it is not a substitute for building an image.
ioc extract-runtime-assets moves files out of its source tree for speed;
run it only in the disposable packaging stage intended by the image build.
Working on a support module#
ibek dev support <module>... # build these modules from clones on the host
ibek dev support <module>... --release # stop building them from the clones
dev support builds each named support module, named as the Dockerfile names
it, from a clone at /workspaces/<module> on the host. It clones the module’s
repository at the version its Dockerfile line gives with -v, or else the
version of its install.yml, or uses a clone of that repository that is
already there, with whatever it has checked out. It removes the module that
the image built, with any edits made in its folder, and links the module’s
support folder to the clone: that is /epics/support/<name>, where <name>
is the module of its install.yml, or the local_path that its
install.yml sets. It then builds the module, the modules after it in the
Dockerfile and the IOC. Run it again to build again after a change. The build
edits some tracked files of a clone, such as configure/RELEASE, and names
them: do not commit those edits. The paths that the build makes are added to
the clone’s .git/info/exclude, between lines that start
# made by an ibek dev build, so git status does not show them: a file
added later under a directory listed there does not show either.
The modules are declared in .ibek-dev.yaml in the generic IOC project, which
is on the host and so outlives the container. In a container that is created
again, dev sync reports them and dev sync --build links and builds them.
With --release, nothing is built: the links and the declarations are removed
and the clones are left alone. The support folder of a module that was linked
is then missing until dev sync --build clones the module at its version and
builds it.