apache-opendal
SUCCESS
70m 14s
History Source
SummaryIterations2Transcript40Dockerfile
Dockerfile80 lines · 3293 chars
# Multi-stage build for Apache OpenDAL bindings (C, C++, and Rust core) on Ubuntu Jammy
# Stage 1: builder - compile C, C++ bindings and Rust core from source
FROM ubuntu:jammy-20260217 AS builder
LABEL maintainer="OpenDAL Build Agent"

ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies required for building OpenDAL bindings
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        build-essential cmake curl ca-certificates pkg-config libssl-dev uuid-dev git \
    && rm -rf /var/lib/apt/lists/*

# Install Rust 1.85 toolchain (as per repository requirements)
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.85.0
ENV PATH="/root/.cargo/bin:${PATH}"

# Install a modern cmake to satisfy minimum version requirements
RUN apt-get update && apt-get install -y --no-install-recommends python3-pip && \
    pip3 install --no-cache-dir 'cmake>=3.27'

WORKDIR /workspace

# Copy source code
COPY . .

# Build OpenDAL C binding (bindings/c) using CMake and Cargo
RUN cmake -S bindings/c -B bindings/c/build -DCMAKE_BUILD_TYPE=Release && \
    cmake --build bindings/c/build --target cargo_build

# Build OpenDAL C++ binding (bindings/cpp) using CMake and Cargo
RUN cmake -S bindings/cpp -B bindings/cpp/build -DCMAKE_BUILD_TYPE=Release && \
    cmake --build bindings/cpp/build --target cargo_build

# Stage 2: runtime image with built artifacts
FROM ubuntu:jammy-20260217
LABEL maintainer="OpenDAL Runtime"

ENV DEBIAN_FRONTEND=noninteractive

# Runtime dependencies (openssl, uuid, etc.)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ca-certificates libssl3 uuid-runtime \
    && rm -rf /var/lib/apt/lists/*

# Copy built artifacts from builder
COPY --from=builder /workspace/bindings/c/target /workspace/bindings/c/target
COPY --from=builder /workspace/bindings/cpp/target /workspace/bindings/cpp/target
COPY --from=builder /workspace/bindings/c/include /workspace/bindings/c/include
COPY --from=builder /workspace/bindings/cpp/include /workspace/bindings/cpp/include

# Install headers and libraries into standard system locations
RUN mkdir -p /usr/local/lib /usr/local/include

# Copy C binding libraries if present
RUN set -eux; \
    mkdir -p /usr/local/lib; \
    cp -f /workspace/bindings/c/target/release/libopendal_c*.so* /usr/local/lib 2>/dev/null || true; \
    cp -f /workspace/bindings/c/target/debug/libopendal_c*.so* /usr/local/lib 2>/dev/null || true; \
    cp -f /workspace/bindings/c/target/release/libopendal_c*.a /usr/local/lib 2>/dev/null || true; \
    cp -f /workspace/bindings/c/target/debug/libopendal_c*.a /usr/local/lib 2>/dev/null || true

# Copy C binding headers
RUN cp -r /workspace/bindings/c/include/* /usr/local/include/ 2>/dev/null || true

# Copy C++ binding libraries (static) if present
RUN set -eux; \
    cp -f /workspace/bindings/cpp/target/release/libopendal_cpp*.a /usr/local/lib 2>/dev/null || true; \
    cp -f /workspace/bindings/cpp/target/debug/libopendal_cpp*.a /usr/local/lib 2>/dev/null || true

# Copy C++ binding headers
RUN cp -r /workspace/bindings/cpp/include/* /usr/local/include/ 2>/dev/null || true

# Ensure runtime linker can find libraries
ENV LD_LIBRARY_PATH=/usr/local/lib

# Set a simple default command shell for debugging
CMD ["/bin/bash"]