Skip to content

Commit 7c58892

Browse files
committed
dev_container completed
1 parent 6f3ad3c commit 7c58892

File tree

3 files changed

+89
-99
lines changed

3 files changed

+89
-99
lines changed

docs/reference/configuration.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,26 @@ TODO: this needs completing - pull all configuration discussions into
77
one place. Most of these will come from the original Setting up the
88
Workspace document.
99

10+
1011
## Git Configuration
1112

1213
```
1314
[url "ssh://[email protected]/"]
1415
insteadOf = https://github.com/
1516
```
17+
18+
## Vscode Settings
19+
20+
These settings can be edited using `Ctrl-Shift-P`: `Preferences: Open User Settings: (JSON)`
21+
22+
(scm_settings)=
23+
### Disable recursive search for git repositories
24+
25+
Because all ioc-XXX have the same submodule `ibek-support` and because `/epics/support` in Generic IOCs contains many repositories, it is best not to automatically have vscode search for git repositories in the workspace. These settings are useful in this regard.
26+
27+
```json
28+
"scm.alwaysShowRepositories": true,
29+
"git.repositoryScanMaxDepth": 0,
30+
"scm.repositories.visible": 12,
31+
```
32+

docs/tutorials/deploy_example.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ Or follow the IOC log until you hit ctrl-C:
249249
ec logs bl01t-ea-test-01 -f
250250
```
251251

252-
You will notice that this IOC simply prints out a message regarding what
253-
you can place in the /epics/ioc/config folder. In the next tutorial
254-
we will look at how to configure a real EPICS IOC.
252+
You should see the log of ibek loading and generating the IOC startup assets and then the ioc shell startup script log.
253+
254+
You can also attach to the IOC and check that it has started correctly by using the 'dbl' command to list all the records in it's IOC database.
255+
256+
```bash
257+
ec attach bl01t-ea-test-01
258+
dbl
259+
# ctrl-p ctrl-q to detach
260+
```
261+

docs/tutorials/dev_container.md

Lines changed: 62 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,62 @@
77
Containerized IOCs can be modified in 3 distinct places (in order of decreasing
88
frequency of change but increasing complexity):
99

10-
1. The IOC instance: this means making changes to the IOC instance folders
11-
which appear in the `iocs` folder of a domain repository. e.g.:
12-
13-
- changing the EPICS DB (or the `ibek` files that generate it)
14-
- altering the IOC boot script (or the `ibek` files that generate it)
15-
- changing the version of the Generic IOC used in values.yaml
16-
- for Kubernetes: the values.yaml can override any settings used by helm
17-
so these can also be adjusted on a per IOC instance basis.
18-
- for Kubernetes: changes to the global values.yaml
19-
file found in `beamline-chart`, these affect all IOCs in the domain.
20-
21-
2. The Generic IOC: i.e. altering how the Generic IOC container image
22-
is built. This means making changes to an `ioc-XXX`
23-
source repo and publishing a new version of the container image.
24-
Types of changes include:
10+
(changes_1)=
11+
### Changing the IOC instance
12+
13+
This means making changes to the IOC instance folders
14+
which appear in the `iocs` folder of an {any}`ec-services-repo`. e.g.:
15+
16+
- changing the EPICS DB (or the `ibek` files that generate it)
17+
- altering the IOC boot script (or the `ibek` files that generate it)
18+
- changing the version of the Generic IOC used in values.yaml
19+
- for Kubernetes: the values.yaml can override any settings used by helm
20+
so these can also be adjusted on a per IOC instance basis.
21+
- for Kubernetes: changes to the global values.yaml
22+
file found in `beamline-chart`, these affect all IOCs in the repository.
23+
24+
(changes_2)=
25+
### Changing the Generic IOC
26+
27+
This involves altering how the Generic IOC container image
28+
is built. This means making changes to an `ioc-XXX`
29+
source repo and publishing a new version of the container image.
30+
Types of changes include:
2531

2632
- changing the EPICS base version
2733
- changing the versions of EPICS support modules compiled into the IOC binary
2834
- adding new support modules
2935
- altering the system dependencies installed into the container image
3036

31-
3. The dependencies - Support modules used by the Generic IOC. Changes to support
32-
module repos. To make use of these changes would require:
33-
34-
- publishing a new release of the support module,
35-
- updating and publishing the Generic IOC
36-
- updating and publishing the IOC instance
37+
(changes_3)=
38+
### Changing the dependencies
3739

38-
For all of the above, the epics-containers approach allows
39-
local testing of the changes before going through the publishing cycle.
40-
This allows us to have a fast 'inner loop' of development and testing.
40+
Sometimes you will need to alter the support modules used by the Generic IOC. To make use of these changes would require:
4141

42-
Also, epics-containers provides a mechanism for creating a separate workspace for
43-
working on all of the above elements in one place.
42+
- publishing a new release of the support module,
43+
- updating and publishing the Generic IOC
44+
- updating and publishing the IOC instance
4445

4546
## Need for a Developer Container
4647

47-
The earlier tutorials were firmly in the realm of `1` above.
48-
It was adequate for us to install a container platform, IDE and python
49-
and that is all we needed.
48+
For all of the above types of changes, the epics-containers approach allows local testing of the changes before going through the publishing cycle. This allows us to have a fast 'inner loop' of development and testing.
5049

51-
Once you get to level `2` changes you need to have compilers and build tools
52-
installed. You might also require system level dependencies. AreaDetector,
53-
that we used earlier has a long list of system dependencies that need to be
54-
installed in order to compile it. Traditionally we have installed all of these
55-
onto developer workstations or separately compiled the dependencies as part of
56-
the build.
50+
Also, epics-containers provides a mechanism for creating a separate workspace for working on all of the above elements in one place.
5751

58-
These tools and dependencies will differ from one Generic IOC to the next.
52+
The earlier tutorials were firmly in the realm of [](changes_1) above. It was adequate for us to install a container platform, IDE and python and that is all we needed.
5953

60-
When using epics-containers we don't need to install any of these tools or
61-
dependencies on our local machine. Instead we can use a developer container,
62-
and in fact our Generic IOC *is* our developer container.
54+
Once you get to level of [](changes_2) you need to have compilers and build tools installed. You might also require system level dependencies. AreaDetector, that we used earlier has a long list of system dependencies that need to be installed in order to compile it. Traditionally we have installed all of these onto developer workstations or separately compiled the dependencies as part of the build.
6355

64-
When the CI builds a Generic IOC it creates
65-
[two targets](https://github.com/orgs/epics-containers/packages?repo_name=ioc-adsimdetector)
56+
These tools and dependencies will differ from one Generic IOC to the next.
6657

67-
```{eval-rst}
58+
When using epics-containers we don't need to install any of these tools or dependencies on our local machine. Instead we can use a developer container, and in fact our Generic IOC *is* our developer container.
6859

69-
:runtime: this target installs only the runtime dependencies into the container.
70-
It also extracts the built runtime assets from the developer target.
60+
When the CI builds a Generic IOC it creates [two targets](https://github.com/orgs/epics-containers/packages?repo_name=ioc-adsimdetector)
7161

72-
The developer stage of the build is a necessary step in order to get a
73-
```
62+
| | |
63+
|---|---|
64+
| **developer** | this target installs all the build tools and build time dependencies into the container image. It then compiles the support modules and IOC. |
65+
| **runtime** | this target installs only the runtime dependencies into the container. It also extracts the built runtime assets from the developer target. |
7466

7567
The developer stage of the build is a necessary step in order to get a
7668
working runtime container. However, we choose to keep this stage as an additional
@@ -154,7 +146,7 @@ because it makes it possible to archive away the development environment
154146
along side the source code. It also means that you can easily share the
155147
development environment with other developers.
156148

157-
For epics-containers the generic IOC >>>is\<\<\< the developer container. When
149+
For epics-containers the generic IOC *is* the developer container. When
158150
you build the developer target of the container in CI it will contain all the
159151
build tools and dependencies needed to build the IOC. It will also contain
160152
the IOC source code and the support module source code. For this reason
@@ -166,7 +158,7 @@ tools to build and test it.
166158
It is also important to understand that although your vscode session is
167159
entirely inside the container, some of your host folders have been mounted
168160
into the container. This is done so that your important changes to source
169-
code would not be lost if the container were rebuilt. See [container-layout]
161+
code would not be lost if the container were rebuilt. See [](container-layout)
170162
for details of which host folders are mounted into the container.
171163

172164
Once built, open the project in VSCode:
@@ -180,13 +172,13 @@ the green icon in the bottom left of the VSCode window and select
180172
`Reopen in Container`.
181173

182174
You should now be *inside* the container. All terminals started in VSCode will
183-
be inside the container. Every file that you open with the VSCode editor
175+
be running inside the container. Every file that you open with the VSCode editor
184176
will be inside the container.
185177

186178
There are some caveats because some folders are mounted from the host file
187179
system. For example, the `ioc-adsimdetector` project folder
188180
is mounted into the container as a volume. It is mounted under
189-
`/epics/ioc-adsimdetector`. This means that you can edit the source code
181+
`/workspaces/ioc-adsimdetector`. This means that you can edit the source code
190182
from your local machine and the changes will be visible inside the container and
191183
outside the container. This is a good thing as you should consider the container
192184
filesystem to be a temporary filesystem that will be destroyed when the container
@@ -210,39 +202,21 @@ it, this includes `ibek`.
210202
The first commands you should run are as follows:
211203

212204
```bash
205+
# open a terminal: Menu -> Terminal -> New Terminal
213206
cd /epics/ioc
214207
make
215208
```
216209

217-
It is useful to understand that /epics/ioc is a soft link to the IOC source
218-
that came with your generic IOC source code. Therefore if you edit this
219-
code and recompile it, the changes will be visible inside the container and
220-
outside the container. Meaning that the repository `ioc-adsimdetector` is
221-
now showing your changes in it's `ioc` folder and you could push them
210+
It is useful to understand that `/epics/ioc` is a soft link to the IOC source that came with your generic IOC source code. Therefore if you edit this code and recompile it, the changes will be visible inside the container and outside the container. Meaning that the repository `ioc-adsimdetector` is now showing your changes in it's `ioc` folder and you could push them
222211
up to GitHub if you wanted.
223212

224-
The above is true because your project folder ioc-adsimdetector is mounted into
225-
the container's filesystem with a bind mount at the same place that the
226-
ioc files were originally placed by the container build.
227-
228-
epics-containers devcontainers have carefully curated host filesystem mounts.
229-
This allows the developer environment to look as similar as possible to the
230-
runtime container.
231-
It also will preserve any important changes that you make in the host file system.
232-
This is essential because the container filesystem is temporary and will be
233-
destroyed when the container is rebuilt or deleted.
213+
epics-containers devcontainers have carefully curated host filesystem mounts. This allows the developer environment to look as similar as possible to the runtime container. It also will preserve any important changes that you make in the host file system. This is essential because the container filesystem is temporary and will be destroyed when the container is rebuilt or deleted.
234214

235-
See [container-layout] for details of which host folders are mounted into the
236-
container.
215+
See [](container-layout) for details of which host folders are mounted into the container.
237216

238-
The IOC source code is entirely boilerplate, `/epics/ioc/iocApp/src/Makefile`
239-
determines which dbd and lib files to link by including two files that
240-
`ibek` generated during the container build. You can see these files in
241-
`/epics/support/configure/lib_list` and `/epics/support/configure/dbd_list`.
217+
The IOC source code is entirely boilerplate, `/epics/ioc/iocApp/src/Makefile` determines which dbd and lib files to link by including two files that `ibek` generated during the container build. You can see these files in `/epics/support/configure/lib_list` and `/epics/support/configure/dbd_list`.
242218

243-
Although all Generic IOCs derived from ioc-template start out with the same
244-
generic source, you are free to change them if there is
245-
a need for different compilation options etc.
219+
Although all Generic IOCs derived from ioc-template start out with the same generic source, you are free to change them if there is a need for different compilation options etc.
246220

247221
The Generic IOC should now be ready to run inside of the container. To do this:
248222

@@ -280,13 +254,15 @@ located.
280254

281255
:::{note}
282256
Docker Users: your account inside the container will not be the owner of
283-
/epics files. vscode will try to open the repos in epics-base and support/\*
257+
/epics files. vscode may try to open the repos in epics-base and support/\*
284258
and git will complain about ownership. You can cancel out of these errors
285259
as you should not edit project folders inside of `/epics` - they were
286260
built by the container and should be considered immutable. We will learn
287261
how to work on support modules in later tutorials. This error should only
288262
be seen on first launch. podman users will have no such problem because they
289263
will be root inside the container and root built the container.
264+
265+
To mitigate this problem you can tell vscode not to look for git repos in subfolders, see [](scm_settings).
290266
:::
291267

292268
You can now easily browse around the `/epics` folder and see all the
@@ -317,6 +293,10 @@ host. i.e. the root folder under which your projects are all cloned):
317293
- WS/ioc-adsimdetector/ioc
318294
- soft link to IOC source tree
319295
296+
* - /epics/runtime
297+
- N/A
298+
- generated startup script and EPICS database files
299+
320300
* - /epics/ibek-defs
321301
- N/A
322302
- All ibek *Support yaml* files
@@ -339,7 +319,7 @@ host. i.e. the root folder under which your projects are all cloned):
339319
340320
* - /epics/generic-source
341321
- WS/ioc-adsimdetector
342-
- A second - fixed location mount of the Generic IOC source repo
322+
- A second - fixed location mount of the Generic IOC source repo to allow `ibek` to find it easily.
343323
```
344324

345325
IMPORTANT: remember that the container filesystem is temporary and will be
@@ -353,39 +333,25 @@ in the host filesystem.
353333
Also note that VSCode keeps your developer container until you rebuild it
354334
or explicitly delete it. Restarting your PC and coming back to the same
355335
devcontainer does keep all state. This can make you complacent about doing
356-
work in the container filesystem, this is not recommended.
336+
work in the container filesystem, but it is still not recommended.
357337

358338
(choose-ioc-instance)=
359339

360340
## Choose the IOC Instance to Test
361341

362-
Now that we have the beamline repo visible in our container we can
363-
easily supply some instance configuration to the Generic IOC.
342+
Now that we have the beamline repo visible in our container we can easily supply some instance configuration to the Generic IOC. This will use the `ibek` tool convenience function `dev instance` which declares which IOC instance you want to work on in the developer container.
343+
364344
Try the following:
365345

366346
```
367347
cd /epics/ioc
368-
rm -r config
369-
ln -s /workspaces/bl01t/services/bl01t-ea-test-02/config .
370-
# check the ln worked
348+
ibek dev instance /workspaces/bl01t/services/bl01t-ea-test-02
349+
# check the it worked - should see a symlink to the config folder
371350
ls -l config
372351
./start.sh
373352
```
374353

375-
This removed the boilerplate config and replaced it with the config from
376-
the IOC instance bl01t-ea-test-02. Note that we used a soft link, this
377-
means we can edit the config, restart the IOC to test it and the changes
378-
will already be in place in the beamline repo. You can even open a shell
379-
onto the beamline repo and commit and push the changes.
380-
381-
:::{note}
382-
The manual steps above were shown to demonstrate the process. In practice
383-
you can use this command to do the same thing:
384-
385-
```bash
386-
ibek dev instance /workspaces/bl01t/services/bl01t-ea-test-02
387-
```
388-
:::
354+
This removed any existing config folder and replaced it with the config from the IOC instance bl01t-ea-test-02 by symlinking to that IOC Instance's config folder. Note that we used a soft link, this means we can edit the config, restart the IOC to test it and the changes will already be in place in the beamline repository. You could therefore open a shell onto the beamline repository at `/workspaces/bl01t` and commit and push the changes.
389355

390356
## Wrapping Up
391357

0 commit comments

Comments
 (0)