From fef5f2b8fa507c32fb8337f25e73d36683fc2619 Mon Sep 17 00:00:00 2001 From: Eric Butcher <107886303+Eric-Butcher@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:50:56 -0400 Subject: [PATCH] Fixed the problem with executable not working due to not finding the correct std library when run in the container. Fixed this by compilling the program inside of a multi-stage container build. --- .containerignore | 14 ++++++++++++++ containers/Containerfile.debian | 19 +++++++++++++++++-- containers/Containerfile.fedora | 22 ++++++++++++++++++++-- src/prngs/mersenne_twister.cpp | 1 + 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 .containerignore diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..1da3f29 --- /dev/null +++ b/.containerignore @@ -0,0 +1,14 @@ +build/ + +.git/ +.github/ +.gitignore + +.vscode/ +.idea/ + +.containerignore +Containerfile + +.clang* +*.py diff --git a/containers/Containerfile.debian b/containers/Containerfile.debian index a665e07..77ebfe3 100644 --- a/containers/Containerfile.debian +++ b/containers/Containerfile.debian @@ -1,9 +1,24 @@ +FROM debian:12 AS builder + +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake + +WORKDIR /app +COPY . . + +RUN mkdir build && cd build && \ + cmake .. && \ + make -j$(nproc) && \ + cpack -G DEB + FROM debian:12 RUN apt-get update && apt-get install -y man man-db less -COPY ../build/out/*.deb . -RUN dpkg -i $(ls *.deb | head -n1) && rm -f ./*.deb +COPY --from=builder /app/build/out/*.deb /tmp/ + +RUN dpkg -i /tmp/*.deb && rm -rf /tmp/*.deb RUN groupadd unprivileged-group && \ useradd -g unprivileged-group -N -m unprivileged-user diff --git a/containers/Containerfile.fedora b/containers/Containerfile.fedora index 414c380..71e75dd 100644 --- a/containers/Containerfile.fedora +++ b/containers/Containerfile.fedora @@ -1,9 +1,27 @@ +FROM fedora:42 AS builder + +RUN dnf install -y \ + gcc-c++ \ + cmake \ + make \ + rpm-build + +WORKDIR /app +COPY . . + +RUN mkdir build && cd build && \ + cmake .. && \ + make -j$(nproc) && \ + cpack -G RPM + FROM fedora:42 RUN dnf install -y man man-pages man-db less --setopt='tsflags=' -COPY ../build/out/*.rpm . -RUN dnf install -y $(ls *.rpm | head -n1) --setopt='tsflags=' && rm -rf ./*.rpm +COPY --from=builder /app/build/out/*.rpm /tmp/ + +RUN dnf install -y /tmp/*.rpm --setopt='tsflags=' && \ + rm -rf /tmp/*.rpm RUN groupadd unprivileged-group && \ useradd -g unprivileged-group -N -m unprivileged-user diff --git a/src/prngs/mersenne_twister.cpp b/src/prngs/mersenne_twister.cpp index 8be28f0..1d0594f 100644 --- a/src/prngs/mersenne_twister.cpp +++ b/src/prngs/mersenne_twister.cpp @@ -1,5 +1,6 @@ #include "mersenne_twister.hpp" #include "prng.hpp" +#include #include #include #include