Skip to contentSkip to conversation

Add simple Alpine container

RFC PATCH In review Richard Palethorpe via ltp 4 participants 6 messages Sep 26, 2023 – Sep 27, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Add simple Alpine container

Can be built with docker/podman build .. Then run with podman -it run sh. It contains Kirk in /opt/kirk. So cd /opt/kirk && ./kirk -f ltp --run-suite syscalls will run some tests.
---

Hello,

This builds and installs the LTP and Kirk inside an Alpine container. The idea is to use a standard container workflow to build and run the LTP from source. This helps with testing LTP itself and running tests inside a container.

I'd like to add some container files to upstream to help with various workflows.

The container has a number of problems:

1. If the Git directory has build artifacts in it, these are copied into the container (.dockerignore may help)
2. The resulting container is quite large (possibly due to debug symbols)
3. Where should we put container files and how should we name them?
4. Making the slightest change results in a complete container rebuild

Note that SUSE publishes a TW container based on our packaging system:
https://build.opensuse.org/project/show/benchmark:ltp:devel
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*

Also, for developing tests, it may be better to build the LTP outside of a container then copy in the files.

Latest tree is here:
https://github.com/richiejp/ltp/tree/alpine-container

 Containerfile | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Containerfile
Containerfile new file +35 -0
new file mode 100644
index 000000000..7bd50ce52
@@ -0,0 +1,35 @@
+FROM alpine:3.18 AS build
+ARG LTPROOT=/opt/ltp
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/alpine.sh
+RUN ./build.sh -p $LTPROOT -i
+
+FROM alpine:3.18
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+
+RUN apk add \
+            acl \
+            keyutils \
+            libaio \
+            libacl \
+            libcap \
+            libselinux \
+            libsepol \
+            libtirpc \
+            numactl \
+            openssl \
+            py3-msgpack
+
+COPY --from=build $LTPROOT $LTPROOT
+ENV LTPROOT=$LTPROOT
+ENV PATH=$LTPROOT/testcases/bin:$LTPROOT/bin:$PATH
+
+RUN mkdir -p $KIRKROOT
+COPY --from=build /build/tools/kirk $KIRKROOT
+
+RUN adduser -D -g "Unprivileged LTP user" ltp
+RUN su ltp
Signature · 5 lines
2.40.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Am Dienstag, 26. September 2023, 11:01:01 CEST schrieb Richard Palethorpe via ltp:

Quoted 12 lines

Can be built with docker/podman build .. Then run with podman -it run sh. It contains Kirk in /opt/kirk. So cd /opt/kirk && ./kirk -f ltp --run-suite syscalls will run some tests.
---

Hello,

This builds and installs the LTP and Kirk inside an Alpine container. The idea is to use a standard container workflow to build and run the LTP from source. This helps with testing LTP itself and running tests inside a container.

Quoted 7 lines

I'd like to add some container files to upstream to help with various workflows.

The container has a number of problems:

1. If the Git directory has build artifacts in it, these are copied into the container (.dockerignore may help)

Doing an out-of-source-tree build might also help. Even just printing a warning/error in case the repository has already been configured might be good enough.

Quoted 1 line

3. Where should we put container files and how should we name them?

Maybe just a subdirectory container and within that one subdirectory for each container.

Quoted 2 lines

Also, for developing tests, it may be better to build the LTP outside of a container then copy in the files.

How would you do that? Relevant container-specific dependencies such as musl are within the container. One had to expose the container's filesystem tree somewhere in the regular filesystem and had to use that as prefix. That doesn't seem like an easy way of doing things.

By the way, to develop "[PATCH v1] Skip cgroup-related tests if /sys/fs/ cgroup readonly" I simply started on a fresh Alpine container, invoked our CI script for installing dependencies, followed the build instructions from the README, committed the container for later use and then just continued developing within the container as usual. (I was still using my editor from outside the container. So the clangd integration still assumed glibc headers. Maybe one could expose the container's filesystem on the host and change include paths via .clangd to prefer musl headers from within the container.)

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hello,

Quoted 17 lines · Marius Kittler

Am Dienstag, 26. September 2023, 11:01:01 CEST schrieb Richard Palethorpe via ltp:

Quoted 15 lines

Can be built with docker/podman build .. Then run with podman -it run sh. It contains Kirk in /opt/kirk. So cd /opt/kirk && ./kirk -f ltp --run-suite syscalls will run some tests.
---

Hello,

This builds and installs the LTP and Kirk inside an Alpine container. The idea is to use a standard container workflow to build and run the LTP from source. This helps with testing LTP itself and running tests inside a container.

I'd like to add some container files to upstream to help with various workflows.

Quoted 8 lines
Quoted 4 lines

The container has a number of problems:

1. If the Git directory has build artifacts in it, these are copied into the container (.dockerignore may help)

Doing an out-of-source-tree build might also help. Even just printing a warning/error in case the repository has already been configured might be good enough.

Good idea, perhaps check with Git that it is a clean checkout. Especially because one could accidentally copy private files into the container.

Quoted 14 lines
Quoted 2 lines

3. Where should we put container files and how should we name them?

Maybe just a subdirectory container and within that one subdirectory for each container.

Quoted 2 lines

Also, for developing tests, it may be better to build the LTP outside of a container then copy in the files.

How would you do that? Relevant container-specific dependencies such as musl are within the container. One had to expose the container's filesystem tree somewhere in the regular filesystem and had to use that as prefix. That doesn't seem like an easy way of doing things.

Quoted 8 lines

By the way, to develop "[PATCH v1] Skip cgroup-related tests if /sys/fs/ cgroup readonly" I simply started on a fresh Alpine container, invoked our CI script for installing dependencies, followed the build instructions from the README, committed the container for later use and then just continued developing within the container as usual. (I was still using my editor from outside the container. So the clangd integration still assumed glibc headers. Maybe one could expose the container's filesystem on the host and change include paths via .clangd to prefer musl headers from within the container.)

I'm not sure, you can export the LTP dir as a volume and use 'podman cp' to copy the headers to somewhere on your host. This does feel hacky though.

I suppose if clangd can run inside the container then it should be possible to export its ports and connect to it from outside. However I just have a checkout of the musl repo and manually search it.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
In reply to Richard Palethorpe via ltp

Hi all,

Quoted 32 lines

Can be built with docker/podman build .. Then run with podman -it run sh. It contains Kirk in /opt/kirk. So cd /opt/kirk && ./kirk -f ltp --run-suite syscalls will run some tests.
---

Hello,

This builds and installs the LTP and Kirk inside an Alpine container. The idea is to use a standard container workflow to build and run the LTP from source. This helps with testing LTP itself and running tests inside a container.

I'd like to add some container files to upstream to help with various workflows.

The container has a number of problems:

1. If the Git directory has build artifacts in it, these are copied into the container (.dockerignore may help)
2. The resulting container is quite large (possibly due to debug symbols)
3. Where should we put container files and how should we name them?
4. Making the slightest change results in a complete container rebuild

Note that SUSE publishes a TW container based on our packaging system:
https://build.opensuse.org/project/show/benchmark:ltp:devel
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*

Also, for developing tests, it may be better to build the LTP outside of a container then copy in the files.

+++ b/Containerfile

Containerfile line 1

Quoted 1 line
Containerfile new file +1 -0
@@ -0,0 +1,35 @@
+FROM alpine:3.18 AS build

Maybe we could use ARG and ENV to allow user to decide which distro to use.
https://stackoverflow.com/questions/76091578/is-it-possible-to-use-an-environment-variable-in-the-from-instruction-of-a-docke
This way we could use various scripts in ci.

Containerfile line 10

Quoted 9 lines
Containerfile new file +9 -0
+ARG LTPROOT=/opt/ltp
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/alpine.sh
+RUN ./build.sh -p $LTPROOT -i
+
+FROM alpine:3.18

Also here.

Quoted 5 lines
Containerfile new file +5 -0
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+
+RUN apk add \
+            acl \

Containerfile line 25

Quoted 10 lines
Containerfile new file +10 -0
+            keyutils \
+            libaio \
+            libacl \
+            libcap \
+            libselinux \
+            libsepol \
+            libtirpc \
+            numactl \
+            openssl \
+            py3-msgpack

This somehow emulates ./ci/alpine.sh (i.e. ./ci/alpine.sh has keyutils-dev, which should install also keyutils as a dependency). We could add a mechanism to ci scripts to install runtime dependencies (e.g. './ci/alpine.sh runtime' would install all runtime dependencies, './ci/alpine.sh runtime-syscalls' would install only runtime dependencies for syscalls).

But better would be to move runtime dependencies to kirk. But unfortunately this part from original Cyril's perl based runltp-ng was not ported to new Andrea's python based runltp-ng/kirk.

Kind regards,
Petr

Quoted 10 lines
Containerfile new file +10 -0
+
+COPY --from=build $LTPROOT $LTPROOT
+ENV LTPROOT=$LTPROOT
+ENV PATH=$LTPROOT/testcases/bin:$LTPROOT/bin:$PATH
+
+RUN mkdir -p $KIRKROOT
+COPY --from=build /build/tools/kirk $KIRKROOT
+
+RUN adduser -D -g "Unprivileged LTP user" ltp
+RUN su ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hello,

Quoted 32 lines · Petr Vorel

Hi all,

Quoted 29 lines

Can be built with docker/podman build .. Then run with podman -it run sh. It contains Kirk in /opt/kirk. So cd /opt/kirk && ./kirk -f ltp --run-suite syscalls will run some tests.
---

Hello,

This builds and installs the LTP and Kirk inside an Alpine container. The idea is to use a standard container workflow to build and run the LTP from source. This helps with testing LTP itself and running tests inside a container.

I'd like to add some container files to upstream to help with various workflows.

The container has a number of problems:

1. If the Git directory has build artifacts in it, these are copied into the container (.dockerignore may help)
2. The resulting container is quite large (possibly due to debug symbols)
3. Where should we put container files and how should we name them?
4. Making the slightest change results in a complete container rebuild

Note that SUSE publishes a TW container based on our packaging system:
https://build.opensuse.org/project/show/benchmark:ltp:devel
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*

Also, for developing tests, it may be better to build the LTP outside of a container then copy in the files.

Quoted 7 lines

Containerfile line 1

Quoted 3 lines

+++ b/Containerfile

Containerfile new file +1 -0
@@ -0,0 +1,35 @@
+FROM alpine:3.18 AS build

Maybe we could use ARG and ENV to allow user to decide which distro to use.
https://stackoverflow.com/questions/76091578/is-it-possible-to-use-an-environment-variable-in-the-from-instruction-of-a-docke
This way we could use various scripts in ci.

Sounds good assuming it does not make the container file too complicated. The scripts you made have been really helpful.

Quoted 24 lines

Containerfile line 10

Quoted 10 lines
Containerfile new file +9 -0
+ARG LTPROOT=/opt/ltp
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/alpine.sh
+RUN ./build.sh -p $LTPROOT -i
+
+FROM alpine:3.18

Also here.

Quoted 12 lines
Containerfile new file +12 -0
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+
+RUN apk add \
+            acl \
+            keyutils \
+            libaio \
+            libacl \
+            libcap \
+            libselinux \
+            libsepol \
+            libtirpc \
Quoted 8 lines

Containerfile line 25

Quoted 3 lines
Containerfile new file +3 -0
+            numactl \
+            openssl \
+            py3-msgpack

This somehow emulates ./ci/alpine.sh (i.e. ./ci/alpine.sh has keyutils-dev, which should install also keyutils as a dependency). We could add a mechanism to ci scripts to install runtime dependencies (e.g. './ci/alpine.sh runtime' would install all runtime dependencies, './ci/alpine.sh runtime-syscalls' would install only runtime dependencies for syscalls).

How about, for now, just an optional 'runtime' flag that only installs runtime deps?

Quoted 4 lines

But better would be to move runtime dependencies to kirk. But unfortunately this part from original Cyril's perl based runltp-ng was not ported to new Andrea's python based runltp-ng/kirk.

Well we could also make an Alpine, Flatpack, Nix package or any number of other ways to build LTP and install the deps. Andrea deliberately chose to decouple that from Kirk. However you could pass the CI scripts to Kirk during test setup. It's just that those scripts don't live inside the Kirk repo.

Quoted 14 lines

Kind regards,
Petr

Quoted 10 lines
Containerfile new file +10 -0
+
+COPY --from=build $LTPROOT $LTPROOT
+ENV LTPROOT=$LTPROOT
+ENV PATH=$LTPROOT/testcases/bin:$LTPROOT/bin:$PATH
+
+RUN mkdir -p $KIRKROOT
+COPY --from=build /build/tools/kirk $KIRKROOT
+
+RUN adduser -D -g "Unprivileged LTP user" ltp
+RUN su ltp
Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Hi all,

...

Quoted 10 lines
Quoted 7 lines

Containerfile line 1

Quoted 3 lines

+++ b/Containerfile

Containerfile new file +1 -0
@@ -0,0 +1,35 @@
+FROM alpine:3.18 AS build

Maybe we could use ARG and ENV to allow user to decide which distro to use.
https://stackoverflow.com/questions/76091578/is-it-possible-to-use-an-environment-variable-in-the-from-instruction-of-a-docke
This way we could use various scripts in ci.

Sounds good assuming it does not make the container file too complicated. The scripts you made have been really helpful.

+1. We would need at least some comment. If there are more things to say, it might be useful to have a wiki page about container based testing (if you have time and energy to write it).

Quoted 32 lines
Quoted 23 lines

Containerfile line 10

Quoted 9 lines
Containerfile new file +9 -0
+ARG LTPROOT=/opt/ltp
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/alpine.sh
+RUN ./build.sh -p $LTPROOT -i
+
+FROM alpine:3.18

Also here.

Quoted 12 lines
Containerfile new file +12 -0
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+
+RUN apk add \
+            acl \
+            keyutils \
+            libaio \
+            libacl \
+            libcap \
+            libselinux \
+            libsepol \
+            libtirpc \
Quoted 8 lines

Containerfile line 25

Quoted 3 lines
Containerfile new file +3 -0
+            numactl \
+            openssl \
+            py3-msgpack

This somehow emulates ./ci/alpine.sh (i.e. ./ci/alpine.sh has keyutils-dev, which should install also keyutils as a dependency). We could add a mechanism to ci scripts to install runtime dependencies (e.g. './ci/alpine.sh runtime' would install all runtime dependencies, './ci/alpine.sh runtime-syscalls' would install only runtime dependencies for syscalls).

Quoted 2 lines

How about, for now, just an optional 'runtime' flag that only installs runtime deps?

Sure, no problem. The real work is to identify these runtime dependencies. I mean not libraries without development headers (headers does not take that much size, thus I would not bother), but various other tools (e.g. ip, ping, mkfs.*, useradd, quotacheck, e4crypt, exportfs, modprobe, rmmod, ...) Some of them are installed on normal distro, but not all; for sure most of them aren't installed in the default container.

Quoted 7 lines
Quoted 3 lines

But better would be to move runtime dependencies to kirk. But unfortunately this part from original Cyril's perl based runltp-ng was not ported to new Andrea's python based runltp-ng/kirk.

Well we could also make an Alpine, Flatpack, Nix package or any number of other ways to build LTP and install the deps. Andrea deliberately chose to decouple that from Kirk. However you could pass the CI scripts

I'm not sure if that was a correct decision. Sure, it might be easier to maintain scripts like this in the projects kirk runs (e.g. LTP, Kselftest), but OTOH I see a benefit in having unified interface for all project (or at least run these upstreamed scripts in kirk in unified way).

Quoted 2 lines

to Kirk during test setup. It's just that those scripts don't live inside the Kirk repo.

+1

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp