This commit is contained in:
@@ -14,21 +14,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
set(CMAKE_PREFIX_PATH /usr/local)
|
||||
|
||||
# Configure version.hpp and create executable
|
||||
# Create executable
|
||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
# Configure version.hpp
|
||||
configure_file("src/version.hpp.in" "src/autogen/version.hpp" @ONLY)
|
||||
|
||||
# Pre-build script
|
||||
add_custom_target(run_prebuild_script ALL
|
||||
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
add_dependencies(${PROJECT_NAME} run_prebuild_script)
|
||||
|
||||
# Include directories
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/autogen src)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src/autogen
|
||||
src)
|
||||
|
||||
# Find packages
|
||||
set(CMAKE_PREFIX_PATH /usr/local)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(Drogon CONFIG REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
@@ -37,4 +43,5 @@ find_package(nlohmann_json REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
nlohmann_json::nlohmann_json Drogon::Drogon
|
||||
/usr/local/lib/libpgcommon.a /usr/local/lib/libpgport.a
|
||||
lzma dl)
|
||||
lzma dl)
|
||||
|
@@ -1,3 +1,4 @@
|
||||
ARG IMAGE_TAG
|
||||
FROM gitea.jde.nz/public/dropshell-build-base:latest AS builder
|
||||
|
||||
ARG PROJECT
|
||||
@@ -20,6 +21,9 @@ COPY . .
|
||||
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 \
|
||||
@@ -35,6 +39,9 @@ RUN --mount=type=cache,target=/ccache \
|
||||
-DCMAKE_STRIP=OFF \
|
||||
-DIGNORE_DYNAMIC_LOADING=ON \
|
||||
-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
|
||||
|
59
clear-cache.sh
Executable file
59
clear-cache.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
echo "🧹 Clearing build caches for simple-object-server"
|
||||
|
||||
# Function to show what we're doing
|
||||
function title() {
|
||||
echo "----------------------------------------"
|
||||
local text="$1"
|
||||
local line_length=40
|
||||
local text_length=${#text}
|
||||
local padding=$(( (line_length - text_length) / 2 ))
|
||||
printf "%*s%s%*s\n" $padding "" "$text" $padding ""
|
||||
echo "----------------------------------------"
|
||||
}
|
||||
|
||||
# Remove local output directory
|
||||
if [ -d "${SCRIPT_DIR}/output" ]; then
|
||||
title "Removing local output directory"
|
||||
rm -rf "${SCRIPT_DIR}/output"
|
||||
echo "✅ Removed ${SCRIPT_DIR}/output"
|
||||
else
|
||||
echo "ℹ️ No local output directory to remove"
|
||||
fi
|
||||
|
||||
# Clear Docker build cache for our project
|
||||
title "Clearing Docker BuildKit cache"
|
||||
|
||||
# Remove any existing builder and recreate it (this clears cache)
|
||||
PROJECT="simple-object-server"
|
||||
docker buildx rm ${PROJECT}-multiarch 2>/dev/null || true
|
||||
echo "✅ Removed Docker buildx builder"
|
||||
|
||||
# Prune Docker build cache
|
||||
docker buildx prune -f
|
||||
echo "✅ Pruned Docker BuildKit cache"
|
||||
|
||||
# Clear Docker system cache (more aggressive)
|
||||
title "Clearing Docker system cache"
|
||||
docker system prune -f
|
||||
echo "✅ Pruned Docker system cache"
|
||||
|
||||
# Optional: Clear all Docker build cache (very aggressive)
|
||||
read -p "🚨 Clear ALL Docker build cache? This affects all projects (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
docker builder prune -af
|
||||
echo "✅ Cleared ALL Docker build cache"
|
||||
else
|
||||
echo "ℹ️ Skipped clearing all Docker build cache"
|
||||
fi
|
||||
|
||||
title "Cache clearing complete"
|
||||
echo "🎉 All caches have been cleared!"
|
||||
echo ""
|
||||
echo "Next build will be from scratch but subsequent builds will be fast again."
|
23
publish.sh
23
publish.sh
@@ -6,6 +6,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
echo "Publishing simple-object-server to gitea.jde.nz/public/simple-object-server:latest"
|
||||
|
||||
PROJECT="simple-object-server"
|
||||
|
||||
|
||||
# FUNCTIONS
|
||||
function title() {
|
||||
echo "----------------------------------------"
|
||||
@@ -24,9 +27,13 @@ function die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create buildx builder if it doesn't exist
|
||||
docker buildx create --name ${PROJECT}-multiarch --use \
|
||||
--driver-opt env.BUILDKIT_MAX_PARALLELISM=4 \
|
||||
2>/dev/null || docker buildx use ${PROJECT}-multiarch
|
||||
|
||||
function build() {
|
||||
local PLATFORM="$1"
|
||||
local PROJECT="simple-object-server"
|
||||
|
||||
# convert linux/amd64 to linux-amd64, windows/amd64 to windows-amd64, etc.
|
||||
local OSARCH="${PLATFORM//\//-}"
|
||||
@@ -34,13 +41,13 @@ function build() {
|
||||
title "Building ${PROJECT} for ${PLATFORM}"
|
||||
|
||||
docker buildx build \
|
||||
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||
--build-arg PROJECT="${PROJECT}" \
|
||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
||||
--output "${SCRIPT_DIR}/output/${OSARCH}" \
|
||||
--platform "${PLATFORM}" \
|
||||
"${SCRIPT_DIR}"
|
||||
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||
--build-arg PROJECT="${PROJECT}" \
|
||||
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
|
||||
--output "${SCRIPT_DIR}/output/${OSARCH}" \
|
||||
--platform "${PLATFORM}" \
|
||||
"${SCRIPT_DIR}"
|
||||
|
||||
mv "${SCRIPT_DIR}/output/${OSARCH}/${PROJECT}" "${SCRIPT_DIR}/output/${PROJECT}-${OSARCH}"
|
||||
rm -rf "${SCRIPT_DIR}/output/${OSARCH}"
|
||||
|
Reference in New Issue
Block a user