thealgorithms-c-plus-plus
SUCCESS
3m 03s
History Source
SummaryIterations1Transcript4Dockerfile
01Iteration 1
WRITEWriteFile· step #1
1s
Dockerfile1073 chars
text44 lines · 1073 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-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"]
WRITEWriteFile· step #2
0s
Dockerfile1068 bytes written
text44 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"]
WRITEWriteFile· step #3
0s
.dockerignore250 bytes written
dockerignore23 lines · 250 chars
# 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/
VERIFYVerifyBuild· step #4
1m 20s
VerifyBuildaccepted
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