#!/bin/bash # build.sh using docker run approach set -euo pipefail # Get script directory - handle different execution contexts if [ -n "${BASH_SOURCE[0]}" ]; then SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" else SCRIPT_DIR="$( cd "$( dirname "$0" )" &> /dev/null && pwd )" fi PROJECT="dehydrate" # Debug output for CI echo "Build script running from: ${SCRIPT_DIR}" echo "Current directory: $(pwd)" echo "CMakeLists.txt exists: $([ -f "${SCRIPT_DIR}/CMakeLists.txt" ] && echo "yes" || echo "no")" # Create persistent build directory mkdir -p "${SCRIPT_DIR}/build" mkdir -p "${SCRIPT_DIR}/output" # Run build in container with mounted directories docker run --rm \ --user "$(id -u):$(id -g)" \ -v "${SCRIPT_DIR}:/src:ro" \ -v "${SCRIPT_DIR}/build:/build" \ -v "${SCRIPT_DIR}/output:/output" \ -e CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}" \ gitea.jde.nz/public/dropshell-build-base:latest \ bash -c " cd /build && \ cmake -G Ninja -S /src -B . \ -DCMAKE_BUILD_TYPE=\${CMAKE_BUILD_TYPE} \ -DPROJECT_NAME=${PROJECT} && \ cmake --build . && \ cp ${PROJECT} /output/ "