Skip to content

Commit 5227eeb

Browse files
use docker compose to launch the dev docker container (#3)
Use docker compose to run the development container. ``` # start slurm in background docker compose up -d # run a terminal docker compose exec slurm bash # rebuild the plugin ./rebuild.sh ``` - remove `run.sh`, `build.sh` - adapt Readme accordingly - I've removed the text around `docker pull ghcr.io/...`, since the `docker build` or `docker compose build` will pull the image automatically.
1 parent 3136c15 commit 5227eeb

File tree

13 files changed

+125
-91
lines changed

13 files changed

+125
-91
lines changed

.github/workflows/build-test-image.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ jobs:
101101
EOF
102102
- run: |
103103
# verify attempting to mount under an non-existent path fails
104-
su testuser -c sh <<\EOF
105-
ci/tests/invalid-mount-point.sh
104+
su testuser -c -m sh <<\EOF
105+
ci/tests/invalid-file.sh
106106
EOF
107107
- run: |
108108
# --uenv-mount=.... without --uenv-mount-file must return an error
109-
su testuser -c sh <<\EOF
110-
srun --uenv-mount=/user-environment -v true |& grep 'srun: error: --uenv-mount'
109+
su testuser -c -m sh <<\EOF
110+
# this is expected to vail
111+
ci/tests/invalid-flags.sh
111112
EOF

ci/tests/invalid-file.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
expect_error()
4+
{
5+
(
6+
set +e
7+
if ! (eval "$1") ; then
8+
return 0
9+
fi
10+
return 1
11+
)
12+
}
13+
export -f expect_error
14+
15+
16+
expect_error 'srun -n 1 --uenv-file=/home/testuser/fs.sqfs --uenv-mount=/path/does/not/exist true'

ci/tests/invalid-flags.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
expect_error()
4+
{
5+
(
6+
set +e
7+
if ! (eval "$1") ; then
8+
return 0
9+
fi
10+
return 1
11+
)
12+
}
13+
export -f expect_error
14+
15+
16+
expect_error 'srun --uenv-mount=/user-environment -v true'

ci/tests/invalid-image.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
#!/bin/bash
22

3-
srun --uenv-file=/does/not/exist true |& grep 'Invalid squashfs image' || exit 1
3+
expect_error()
4+
{
5+
(
6+
set +e
7+
if ! (eval "$1") ; then
8+
return 0
9+
fi
10+
return 1
11+
)
12+
}
13+
export -f expect_error
14+
15+
expect_error 'srun --uenv-file=/does/not/exist true'

ci/tests/invalid-mount-point.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

ci/tests/squashfs-run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
set -x
34
# pretend to run inside squasfsh-run ... bash
45
export UENV_MOUNT_FILE=/home/testuser/fs.sqfs
56
export UENV_MOUNT_POINT=/tmp
@@ -8,4 +9,5 @@ srun stat /tmp/test/fileA.txt
89

910
# use --uenv-file to override UENV_MOUNT_FILE
1011
# expectation: squahfs is mounted in `/user-environment/` (default location)
12+
1113
srun --uenv-file=/home/testuser/fs2.sqfs stat /user-environment/test/fileB.txt

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN zypper install -y\
1414
unzip \
1515
rpm-build \
1616
autoconf\
17+
libcap-progs \
1718
automake\
1819
libtool \
1920
xz-devel\

docker/Readme.md

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,33 @@ docker login --username=<USERNAME> ghcr.io
1313
```
1414
When using GitHub Packages, `USERNAME` can be any text. The password is the GitHub Token.
1515

16-
Next pull the container from GitHub Packages.
16+
Build the container (container name `slurm-uenv-mount`, service name `slurm`):
1717
```bash
18-
docker pull <DOCKER_CONTAINER>
19-
```
20-
`DOCKER_CONTAINER` is the full name of the slurm container. This will typically
21-
be something like `ghcr.io/eth-cscs/slurm-container-SLURM_VERSION:latest`.
22-
For instance,
23-
```bash
24-
docker pull ghcr.io/eth-cscs/slurm-container-20.11.9:latest
18+
docker compose build
2519
```
2620

27-
Now build a container named `slurm-uenv-mount` that contains the Slurm server, clients, and the plugin.
28-
The `Dockerfile` in this directory needs to use the same `DOCKER_CONTAINER` pulled earlier.
29-
Either edit `Dockerfile` and replace the name of the default root container or supply the name on the commandline.
30-
```bash
31-
./build.sh [DOCKER_CONTAINER]
32-
```
21+
By default the plugin is built in a container with slurm `20.11.9`. The version
22+
can be changed in `docker-compose.yaml` (check
23+
github.com/eth-cscs/slurm-container for a list of available versions).
3324

34-
The Dockerfile creates user `testuser` for running slurm commands as a normal user. The container itself should run
35-
as privileged to allow the slurm server to start.
36-
37-
Run the container and start an interactive session as the unprivileged user `testuser`:
25+
Start the container in the background:
3826
```bash
39-
docker run --name slurm-uenv-mount --rm --privileged -it slurm-uenv-mount bash
27+
docker compose up -d
4028
```
29+
- The source tree is mounted read-only under `/slurm-uenv-mount`.
4130

42-
Alternatively, `run.sh` can be used as a shortcut:
31+
Launch a shell in the container as unprivileged user:
4332
```bash
44-
./run.sh bash
33+
docker compose exec -u testuser -w /home/testuser slurm bash
4534
```
4635

47-
`./rebuild.sh` rebuilds the plugin in the container from the local source tree (this assumes the container was started via `./run.sh`).
48-
49-
# Rebuilding the plugin
50-
51-
The `run.sh` script mounts the source code directory as a read-only volume inside the container under `/slurm-uenv-mount`.
52-
This allows the source code to be modified outside of the container, but rebuilt and tested in a slurm environment.
53-
To rebuild the plugin, first create a build directory in the `testuser` home inside a running container.
54-
Then run `make` from the build directory, specifying the Makefile from the source directory.
36+
Run tests:
5537
```bash
56-
mkdir BUILD
57-
cd BUILD
58-
make -f /slurm-uenv-mount/Makefile
38+
docker compose exec -u testuser -w /home/testuser -T slurm bash < run-tests.sh
5939
```
6040

61-
Similarly, the source RPM can be build by specifying the `rpm` target.
41+
The source code is mounted read-only inside the container under `/slurm-uenv-mount`.
42+
When making changes in the local source tree, the plugin can be rebuilt/resintalled in the running container with the following script:
6243
```bash
63-
make -f /slurm-uenv-mount/Makefile rpm
44+
./rebuild.sh
6445
```

docker/build.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

docker/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
slurm:
3+
privileged: true
4+
container_name: slurm-uenv-mount
5+
volumes:
6+
- ../:/slurm-uenv-mount:ro
7+
build:
8+
context: ../
9+
args:
10+
DOCKER_CONTAINER: ghcr.io/eth-cscs/slurm-container-20.11.9:latest
11+
dockerfile: docker/Dockerfile
12+
command: tail -F anything

0 commit comments

Comments
 (0)