Skip to contentSkip to conversation

Add simple Containerfile

PATCH Superseded Richard Palethorpe via ltp 4 participants 9 messages Sep 28, 2023 – Oct 10, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add simple Containerfile

This adds a regular container (or Docker) file which builds LTP from source. This is initially intended for testing the LTP itself.

The resulting container has just the LTP installation and runtime dependencies. However it is still quite large, probably due to debug symbols.

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build -t alpine/ltp .

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*
This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>

---

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.
* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch
* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

 .dockerignore            |  1 +
 Containerfile            | 32 ++++++++++++++++++++++++++++++++
 ci/alpine-runtime.sh     | 16 ++++++++++++++++
 ci/tumbleweed-runtime.sh | 13 +++++++++++++
 4 files changed, 62 insertions(+)
 create mode 100644 .dockerignore
 create mode 100644 Containerfile
 create mode 100755 ci/alpine-runtime.sh
 create mode 100755 ci/tumbleweed-runtime.sh
.dockerignore new file +1 -0
new file mode 100644
index 000000000..bbcd7072f
@@ -0,0 +1 @@
+Containerfile
Containerfile new file +32 -0
new file mode 100644
index 000000000..2f8192c3b
@@ -0,0 +1,32 @@
+ARG PREFIX=docker.io/
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE AS build
+ARG LTPROOT=/opt/ltp
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+ARG DISTRO_NAME=alpine
+
+COPY --from=build /build/ci/${DISTRO_NAME}-runtime.sh $LTPROOT/runtime-deps.sh
+RUN $LTPROOT/runtime-deps.sh
+
+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
+
+USER ltp
ci/alpine-runtime.sh new file +16 -0
new file mode 100755
index 000000000..e4941f329
@@ -0,0 +1,16 @@
+#!/bin/sh -eux
+
+apk add \
+        acl \
+        keyutils \
+        libaio \
+        libacl \
+        libcap \
+        libselinux \
+        libsepol \
+        libtirpc \
+        numactl \
+        openssl \
+        py3-msgpack
+
+adduser -D -g "Unprivileged LTP user" ltp
ci/tumbleweed-runtime.sh new file +13 -0
new file mode 100755
index 000000000..5207988e7
@@ -0,0 +1,13 @@
+#!/bin/sh -eux
+
+zyp="zypper --non-interactive install --force-resolution --no-recommends"
+
+$zyp \
+	iproute2 \
+	keyutils \
+	libaio1 \
+	libmnl0 \
+	libnuma1 \
+	libtirpc3
+
+useradd ltp
Signature · 5 lines
2.40.1


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

Hi Richie,

I suppose this is v2 of "[RFC] Add simple Alpine container" [1], thus I set [1] in patchwork as superseded.

This LGTM, thanks! Minor comments below.

Quoted 31 lines

This adds a regular container (or Docker) file which builds LTP from source. This is initially intended for testing the LTP itself.

The resulting container has just the LTP installation and runtime dependencies. However it is still quite large, probably due to debug symbols.

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build -t alpine/ltp .

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*
This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>
Quoted 6 lines

---

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

FYI what we do in release scripts, is to do a local clone to a different directory [2]:
git clone ltp ltp-full-YYYYMMDD

Not sure what is faster.

Quoted 3 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch

+1

But maybe put it into container directory, because it's not used in GitHub CI?

Quoted 2 lines

* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

+1

Quoted 51 lines
.dockerignore new file +1 -0
new file mode 100644
index 000000000..bbcd7072f
@@ -0,0 +1 @@
+Containerfile
Containerfile new file +32 -0
new file mode 100644
index 000000000..2f8192c3b
@@ -0,0 +1,32 @@
+ARG PREFIX=docker.io/
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE AS build
+ARG LTPROOT=/opt/ltp
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+ARG DISTRO_NAME=alpine
+
+COPY --from=build /build/ci/${DISTRO_NAME}-runtime.sh $LTPROOT/runtime-deps.sh
+RUN $LTPROOT/runtime-deps.sh
+
+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
+
+USER ltp
ci/alpine-runtime.sh new file +0 -0
new file mode 100755
index 000000000..e4941f329

ci/alpine-runtime.sh line 1

Quoted 1 line
ci/alpine-runtime.sh new file +1 -0
@@ -0,0 +1,16 @@
+#!/bin/sh -eux

nit: out of curiosity, why -u (fail unset variables and parameters)?

ci/alpine-runtime.sh line 14

Quoted 13 lines
ci/alpine-runtime.sh new file +13 -0
+
+apk add \
+        acl \
+        keyutils \
+        libaio \
+        libacl \
+        libcap \
+        libselinux \
+        libsepol \
+        libtirpc \
+        numactl \
+        openssl \
+        py3-msgpack

I'd add more runtime packages (at least for syscalls). If I manage next week to test this I might ask for more packages, but let's start with this

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
[2] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

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

Hi Richie,

I suppose this is v2 of "[RFC] Add simple Alpine container" [1], thus I set [1] in patchwork as superseded.

This LGTM, thanks! Minor comments below.

Quoted 31 lines

This adds a regular container (or Docker) file which builds LTP from source. This is initially intended for testing the LTP itself.

The resulting container has just the LTP installation and runtime dependencies. However it is still quite large, probably due to debug symbols.

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build -t alpine/ltp .

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*
This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>
Quoted 6 lines

---

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

Quoted 5 lines

FYI what we do in release scripts, is to do a local clone to a different directory [2]:
git clone ltp ltp-full-YYYYMMDD

Not sure what is faster.

I guess that is something a script could also do then 'git clean' becomes a null op. git clean -X will only remove untracked files so pending changes should get picked up. Which is probably what people want during development. Doing a fresh checkout is probably more like a hard reset and clean.

AFAICT git clean is very quick, far faster than 'make distclean'.

Quoted 8 lines
Quoted 4 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch

+1

But maybe put it into container directory, because it's not used in GitHub CI?

I was thinking it could be used in CI. All we need is a CI that runs VMs and we can do some testing. (e.g. srchut).

Quoted 52 lines
Quoted 3 lines

* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

+1

Quoted 46 lines
.dockerignore new file +1 -0
new file mode 100644
index 000000000..bbcd7072f
@@ -0,0 +1 @@
+Containerfile
Containerfile new file +32 -0
new file mode 100644
index 000000000..2f8192c3b
@@ -0,0 +1,32 @@
+ARG PREFIX=docker.io/
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE AS build
+ARG LTPROOT=/opt/ltp
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+ARG DISTRO_NAME=alpine
+
+COPY --from=build /build/ci/${DISTRO_NAME}-runtime.sh $LTPROOT/runtime-deps.sh
+RUN $LTPROOT/runtime-deps.sh
+
+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
+
+USER ltp
ci/alpine-runtime.sh +0 -0
Quoted 8 lines

ci/alpine-runtime.sh line 1

Quoted 6 lines

new file mode 100755
index 000000000..e4941f329

ci/alpine-runtime.sh new file +1 -0
@@ -0,0 +1,16 @@
+#!/bin/sh -eux

nit: out of curiosity, why -u (fail unset variables and parameters)?

I find it finds errors in shell scripts or when using them. E.g. typo's in env variable names. I just include it wherever possible.

Quoted 8 lines
Quoted 8 lines
ci/alpine-runtime.sh new file +8 -0
+
+apk add \
+        acl \
+        keyutils \
+        libaio \
+        libacl \
+        libcap \
+        libselinux \
Quoted 8 lines

ci/alpine-runtime.sh line 14

Quoted 5 lines
ci/alpine-runtime.sh new file +5 -0
+        libsepol \
+        libtirpc \
+        numactl \
+        openssl \
+        py3-msgpack

I'd add more runtime packages (at least for syscalls). If I manage next week to test this I might ask for more packages, but let's start with this

+1

Quoted 6 lines

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
[2] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Signature · 5 lines
Thank you,
Richard.

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

Hi Richie,

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

FYI what we do in release scripts, is to do a local clone to a different directory [2]:
git clone ltp ltp-full-YYYYMMDD

Quoted 5 lines
Quoted 1 line

Not sure what is faster.

I guess that is something a script could also do then 'git clean' becomes a null op. git clean -X will only remove untracked files so pending changes should get picked up. Which is probably what people want

"remove untracked files" - if you develop a new test, forget to add it with 'git add' and run the container, you will get disappointed :).

Quoted 2 lines

during development. Doing a fresh checkout is probably more like a hard reset and clean.

The benefit is that you have not only a clean git repo for the container, but also not touching your working copy directory. But unless nobody else raise any concern, I'm ok with your current proposal.

Quoted 6 lines

AFAICT git clean is very quick, far faster than 'make distclean'.

Quoted 3 lines
Quoted 3 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch

Quoted 7 lines
Quoted 4 lines

+1

But maybe put it into container directory, because it's not used in GitHub CI?

I was thinking it could be used in CI. All we need is a CI that runs VMs and we can do some testing. (e.g. srchut).

Makes sense. Also, having scripts on two directories can lead to confusion, let's keep it in ci directory.

...

Quoted 5 lines
Quoted 2 lines
Quoted 1 line

+#!/bin/sh -eux

nit: out of curiosity, why -u (fail unset variables and parameters)?

I find it finds errors in shell scripts or when using them. E.g. typo's in env variable names. I just include it wherever possible.

+1, maybe we should add it to the current ci scripts as well (+ use params instead of setting it via set command, it should work in dash and busybox shell as well).

Kind regards,
Petr

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

Hello,

Quoted 10 lines · Petr Vorel

Hi Richie,

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

FYI what we do in release scripts, is to do a local clone to a different directory [2]:
git clone ltp ltp-full-YYYYMMDD

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Not sure what is faster.

I guess that is something a script could also do then 'git clean' becomes a null op. git clean -X will only remove untracked files so pending changes should get picked up. Which is probably what people want

"remove untracked files" - if you develop a new test, forget to add it with 'git add' and run the container, you will get disappointed :).

Possibly it is only files that are not tracked due to .gitignore. At least that is how I interpret the Git help. Either way it's not such a concern due to the below.

Quoted 7 lines
Quoted 3 lines

during development. Doing a fresh checkout is probably more like a hard reset and clean.

The benefit is that you have not only a clean git repo for the container, but also not touching your working copy directory. But unless nobody else raise any concern, I'm ok with your current proposal.

Ah I think I see your concern now. It does not touch the directory outside the container. It copies everything in first (IDK if it actually copies the data if you are doing a local build).

Note that I tried using a .dockerignore to stop build artifacts being copied, but it's not as rich as the .gitignore(s) we have sprinkled throughout the LTP.

Quoted 20 lines
Quoted 7 lines

AFAICT git clean is very quick, far faster than 'make distclean'.

Quoted 3 lines
Quoted 3 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch

Quoted 7 lines
Quoted 4 lines

+1

But maybe put it into container directory, because it's not used in GitHub CI?

I was thinking it could be used in CI. All we need is a CI that runs VMs and we can do some testing. (e.g. srchut).

Makes sense. Also, having scripts on two directories can lead to confusion, let's keep it in ci directory.

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

+#!/bin/sh -eux

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

nit: out of curiosity, why -u (fail unset variables and parameters)?

I find it finds errors in shell scripts or when using them. E.g. typo's in env variable names. I just include it wherever possible.

+1, maybe we should add it to the current ci scripts as well (+ use params instead of setting it via set command, it should work in dash and busybox shell as well).

Yeah, I think it should be the default.

Quoted 3 lines

Kind regards,
Petr

Signature · 5 lines
Thank you,
Richard.

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

Hi Richie,

...

Quoted 7 lines
Quoted 3 lines

The benefit is that you have not only a clean git repo for the container, but also not touching your working copy directory. But unless nobody else raise any concern, I'm ok with your current proposal.

Ah I think I see your concern now. It does not touch the directory outside the container. It copies everything in first (IDK if it actually copies the data if you are doing a local build).

Ah, sorry, of course.

Quoted 3 lines

Note that I tried using a .dockerignore to stop build artifacts being copied, but it's not as rich as the .gitignore(s) we have sprinkled throughout the LTP.

...

Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

+#!/bin/sh -eux

nit: out of curiosity, why -u (fail unset variables and parameters)?

I find it finds errors in shell scripts or when using them. E.g. typo's in env variable names. I just include it wherever possible.

+1, maybe we should add it to the current ci scripts as well (+ use params instead of setting it via set command, it should work in dash and busybox shell as well).

Yeah, I think it should be the default.

I add it at least to the original scripts in ci directory, it should be safe here. I'll test tst_test.sh and tst_net.sh and send a patch for this.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw
In reply to Richard Palethorpe via ltp
Quoted 9 lines

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

Quoted 7 lines

podman build -t alpine/ltp .

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

It would likely make sense to add a section with these information in the README as well.

I'm also wondering about the workflow of making changes (e.g. to a single test) and then re-compiling and re-running the specific test. Maybe that's also worth considering/documenting.

Quoted 9 lines

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenc
hmark+container%3D.* This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>
Quoted 6 lines

---

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

Where we document the usage of the container we should also document that it'll do this kind of cleanup so there are no surprises.

Quoted 6 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch
* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

…

Containerfile line 16

Quoted 7 lines
Containerfile new file +7 -0
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+

It might make sense to combine consecutive run commands (see
https://github.com/hadolint/hadolint/wiki/DL3059).

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

Hello,

Quoted 11 lines · Marius Kittler
Quoted 11 lines

The container can be built with a command like:

podman build -t tumbleweed/ltp \
       --build-arg PREFIX=registry.opensuse.org/opensuse/ \
       --build-arg DISTRO_NAME=tumbleweed \
       --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build -t alpine/ltp .

Quoted 8 lines
Quoted 5 lines

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

It would likely make sense to add a section with these information in the README as well.

I agree, but I think I will be doing some more work with containers with Kirk and LTX. So I would prefer to document it after I know more about the best workflow.

Quoted 4 lines

I'm also wondering about the workflow of making changes (e.g. to a single test) and then re-compiling and re-running the specific test. Maybe that's also worth considering/documenting.

TBH I don't have a good workflow for that. I know that we can mount the source in a volume. However we probably need to move the build out of the tree. I'd be interested in suggestions.

Quoted 12 lines
Quoted 12 lines

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenc
hmark+container%3D.* This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>

---

Quoted 7 lines
Quoted 4 lines

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.

Where we document the usage of the container we should also document that it'll do this kind of cleanup so there are no surprises.

To be clear this only happens inside the container and *should* only remove things covered by .gitignore (i.e. build artifacts). So does it need documenting in that case?

Quoted 8 lines
Quoted 7 lines

* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch
* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

…

Quoted 10 lines

Containerfile line 16

Quoted 7 lines
Containerfile new file +7 -0
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+

It might make sense to combine consecutive run commands (see
https://github.com/hadolint/hadolint/wiki/DL3059).

I think this depends on exactly how caching works and where the best place to put git clean is. Ideally we only want to run the ci script when the dependencies change.

Maybe we should also split the COPY, to make sure the container runtime can detect which files have changed.

More importantly I think this relates to your comment on workflow for changing a single test. Ideally we should be able to change and compile a single test without doing a bunch of unecessary work. Right now I am not sure how to do that?

Signature · 5 lines
Thank you,
Richard.

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

Hi,

thanks for this patch. It's really useful.

Regards,
Andrea Cervesato

Quoted 139 lines · Richard Palethorpe via ltp

This adds a regular container (or Docker) file which builds LTP from source. This is initially intended for testing the LTP itself.

The resulting container has just the LTP installation and runtime dependencies. However it is still quite large, probably due to debug symbols.

The container can be built with a command like:

podman build -t tumbleweed/ltp \
        --build-arg PREFIX=registry.opensuse.org/opensuse/ \
        --build-arg DISTRO_NAME=tumbleweed \
        --build-arg DISTRO_RELEASE=20230925 .

Or just

podman build -t alpine/ltp .

It contains Kirk in /opt/kirk. So

cd /opt/kirk && ./kirk -f ltp -r syscalls

will run some tests.

Note a much smaller container can be found at:
https://registry.opensuse.org/cgi-bin/cooverview?srch_term=project%3D%5Ebenchmark+container%3D.*
This is created with SUSE's build system which does not use container files

Cc Petr Vorel <[email protected]>
Cc Marius Kittler <[email protected]>

---

RFC comments:
* Add git clean -fdX which should remove any build artifacts this is different from the suggestion of just doing a check. I just found it easier to remove the build files.
* Added seperate alpine and tumbleweed runtime scripts. Again it's different from the suggestion just because it's easier to add seperate scripts than adding a switch
* Obviously a number of distros are missing runtime scripts. They can be added when someone is motivated to do so.

  .dockerignore            |  1 +
  Containerfile            | 32 ++++++++++++++++++++++++++++++++
  ci/alpine-runtime.sh     | 16 ++++++++++++++++
  ci/tumbleweed-runtime.sh | 13 +++++++++++++
  4 files changed, 62 insertions(+)

create mode 100644 .dockerignore
create mode 100644 Containerfile
create mode 100755 ci/alpine-runtime.sh
create mode 100755 ci/tumbleweed-runtime.sh

.dockerignore new file +1 -0
new file mode 100644
index 000000000..bbcd7072f
@@ -0,0 +1 @@
+Containerfile
Containerfile new file +32 -0
new file mode 100644
index 000000000..2f8192c3b
@@ -0,0 +1,32 @@
+ARG PREFIX=docker.io/
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE AS build
+ARG LTPROOT=/opt/ltp
+ARG DISTRO_NAME=alpine
+ARG DISTRO_RELEASE=3.18
+
+RUN mkdir /build
+WORKDIR /build
+COPY . /build
+RUN ./ci/${DISTRO_NAME}.sh
+RUN git clean -fdX
+RUN ./build.sh -p $LTPROOT -i
+
+FROM $PREFIX$DISTRO_NAME:$DISTRO_RELEASE
+ARG LTPROOT=/opt/ltp
+ARG KIRKROOT=/opt/kirk
+ARG DISTRO_NAME=alpine
+
+COPY --from=build /build/ci/${DISTRO_NAME}-runtime.sh $LTPROOT/runtime-deps.sh
+RUN $LTPROOT/runtime-deps.sh
+
+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
+
+USER ltp
ci/alpine-runtime.sh new file +16 -0
new file mode 100755
index 000000000..e4941f329
@@ -0,0 +1,16 @@
+#!/bin/sh -eux
+
+apk add \
+        acl \
+        keyutils \
+        libaio \
+        libacl \
+        libcap \
+        libselinux \
+        libsepol \
+        libtirpc \
+        numactl \
+        openssl \
+        py3-msgpack
+
+adduser -D -g "Unprivileged LTP user" ltp
ci/tumbleweed-runtime.sh new file +13 -0
new file mode 100755
index 000000000..5207988e7
@@ -0,0 +1,13 @@
+#!/bin/sh -eux
+
+zyp="zypper --non-interactive install --force-resolution --no-recommends"
+
+$zyp \
+	iproute2 \
+	keyutils \
+	libaio1 \
+	libmnl0 \
+	libnuma1 \
+	libtirpc3
+
+useradd ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp