thealgorithms-c-plus-plus
SUCCESS
3m 03s
History Source
SummaryIterations1Transcript4Dockerfile
Dockerfile44 lines · 1068 chars
# 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"]