# Multi-stage build for TheAlgorithms/C-Plus-Plus
# Builder stage: compile from source
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 \
libomp-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy repository source
COPY . .
# Configure and build with OpenMP support
RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DUSE_OPENMP=ON \
&& cmake --build build --parallel
# Runtime stage: smaller image with the built artifacts
FROM ubuntu:22.04-slim AS runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libgomp1 \
libc6 \
libstdc++6 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy built binaries from builder
COPY --from=builder /src/build /opt/algorithms/build
WORKDIR /opt/algorithms/build
# Keep a shell around for manual inspection, or customize to run a test binary
CMD ["/bin/bash"]
# Multi-stage build for TheAlgorithms/C-Plus-Plus
# Builder stage: compile from source
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 \
libomp-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy repository source
COPY . .
# Configure and build with OpenMP support
RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DUSE_OPENMP=ON \
&& cmake --build build --parallel
# Runtime stage: smaller image with the built artifacts
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libgomp1 \
libc6 \
libstdc++6 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy built binaries from builder
COPY --from=builder /src/build /opt/algorithms/build
WORKDIR /opt/algorithms/build
# Keep a shell around for manual inspection, or customize to run a test binary
CMD ["/bin/bash"]
# Docker ignore file for TheAlgorithms/C-Plus-Plus repository .git build/ CMakeFiles/ CMakeCache.txt cmake_install.cmake Makefile *.o *.a *.so *.dll *.dylib *.log *.tmp *.swp *.DS_Store .vscode/ .idea/ node_modules/ doc/html/ doc/styles/ doc/assets/
Concerns: COPY . . copies the entire repository into the build context; consider adding a .dockerignore to avoid sending unnecessary files (e.g., Git metadata, large docs) to the build context, No explicit validation or testing of the built binaries is performed in the Dockerfile; the runtime CMD opens a shell, so smoke tests rely on external commands to locate and exercise a binary Smoke [PASS]: test -d /opt/algorithms/build Smoke [PASS]: find /opt/algorithms/build -type f -executable -print | head -n 1 Smoke [PASS]: if found=$(find /opt/algorithms/build -type f -executable -print | head -n 1); then echo found_executable=$found; else echo no_executable; fi