Dockerfile43 lines · 1019 chars # Multi-stage build for libevent
# Builder stage: compile libevent from source using CMake
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
pkg-config \
zlib1g-dev \
libssl-dev \
libmbedtls-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy source
WORKDIR /src
COPY . /src
# Build and install
RUN mkdir -p build && cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& cmake --build . -- -j"$(nproc)" \
&& cmake --build . --target install
# Runtime stage: minimal image with the built library
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Copy installed libs from builder
COPY --from=builder /usr/local /usr/local
# Ensure dynamic linker can find libraries installed to /usr/local
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
WORKDIR /work
CMD ["bash"]