FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake zlib1g-dev libmbedtls-dev libssl-dev pkg-config ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Build from source inside the image
WORKDIR /usr/src/libevent
# Copy the source into the image
COPY . .
# Configure and build the project from source, and install it
RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build -- -j$(nproc) \
&& cmake --install build
# Update the shared library cache for installed in /usr/local
RUN ldconfig
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Default to an interactive shell so the container remains usable
CMD ["/bin/bash"]
# Ignore VCS and caches .git .gitignore **/.git **/.gitignore node_modules build dist CMakeFiles CMakeCache.txt .cmake *.log *.o *.a *.so *.pyc .DS_Store
Smoke [FAIL]: cd /usr/src/libevent/build && ctest --output-on-failure Output: sh: 1: set: Illegal option -o pipefail
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake zlib1g-dev libmbedtls-dev libssl-dev pkg-config ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Ensure /bin/sh supports bash-style options used by test scripts
RUN ln -sf /bin/bash /bin/sh
# Build from source inside the image
WORKDIR /usr/src/libevent
# Copy the source into the image
COPY . .
# Configure and build the project from source, and install it
RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build -- -j$(nproc) \
&& cmake --install build
# Update the shared library cache for installed in /usr/local
RUN ldconfig
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
# Default to an interactive shell so the container remains usable
CMD ["/bin/bash"]
Concerns: COPY . . assumes source contains a valid CMakeLists.txt and buildable project; if the repo layout differs or CMake configuration is missing, the build will fail., The presence and naming of the libevent pkg-config file can vary by distribution; if libevent.pc is not installed to /usr/local/lib/pkgconfig, the smoke test may fail to link against the library.
Smoke [PASS]: printf '%s\n' '#include <event2/event.h>' '' 'int main(void) {' ' struct event_base *base = event_base_new();' ' if (!base) return 1;' ' event_base_free(base);' ' putchar(111);' ' putchar(107);' ' putchar(10);' ' return 0;' '}' > /tmp/test.c && cc /tmp/test.c -o /tmp/test $(pkg-config --cflags --libs libevent) && /tmp/test | grep -q ok