dropshell-build/Dockerfile.dropshell-build
Your Name eeb5d44b73
Some checks failed
dropshell-build / build (push) Failing after 51m54s
'Generic Commit'
2025-06-14 18:17:57 +12:00

72 lines
2.2 KiB
Docker

FROM gitea.jde.nz/public/dropshell-build-base:latest AS builder
ARG PROJECT
ARG CMAKE_BUILD_TYPE=Debug
# Set working directory
WORKDIR /app
# Create cache directories
RUN mkdir -p /ccache /build-cache
# Set up ccache
ENV CCACHE_DIR=/ccache
ENV CCACHE_COMPILERCHECK=content
ENV CCACHE_MAXSIZE=2G
COPY . .
# Multi-architecture OpenSSL detection handled in cmake step
# Configure and build with ccache using cache mounts
RUN --mount=type=cache,target=/ccache \
--mount=type=cache,target=/build \
mkdir -p /build && \
SSL_LIB=$(find /usr/local -name "libssl.a" | head -1) && \
CRYPTO_LIB=$(find /usr/local -name "libcrypto.a" | head -1) && \
echo "Found SSL: $SSL_LIB, Crypto: $CRYPTO_LIB" && \
cmake -G Ninja -S /app -B /build \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold -static -g" \
-DCMAKE_CXX_FLAGS="-g -fno-omit-frame-pointer" \
-DCMAKE_C_FLAGS="-g -fno-omit-frame-pointer" \
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-DZLIB_BUILD_SHARED=OFF \
-DZLIB_BUILD_STATIC=ON \
-DBUILD_SHARED_LIBS=OFF \
-DPROJECT_NAME="${PROJECT}" \
-DCMAKE_STRIP=OFF \
-DIGNORE_DYNAMIC_LOADING=ON \
-DOPENSSL_ROOT_DIR=/usr/local \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DOPENSSL_SSL_LIBRARY="$SSL_LIB" \
-DOPENSSL_CRYPTO_LIBRARY="$CRYPTO_LIB" \
-DOPENSSL_INCLUDE_DIR=/usr/local/include \
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
# Build with cache mounts
RUN --mount=type=cache,target=/ccache \
--mount=type=cache,target=/build \
cmake --build /build --target run_prebuild_script
RUN --mount=type=cache,target=/ccache \
--mount=type=cache,target=/build \
cmake --build /build
# Copy the built executable to a regular directory for the final stage
RUN --mount=type=cache,target=/build \
mkdir -p /output && \
find /build -type f -executable -name "*${PROJECT}*" -exec cp {} /output/${PROJECT} \; || \
find /build -type f -executable -exec cp {} /output/${PROJECT} \;
# Final stage that only contains the binary
FROM scratch AS project
ARG PROJECT
# Copy the actual binary from the regular directory
COPY --from=builder /output/${PROJECT} /${PROJECT}