'Generic Commit'
Some checks failed
dropshell-build / build (push) Has been cancelled

This commit is contained in:
Your Name 2025-06-14 22:07:46 +12:00
parent e4d0661d50
commit 1ac00e83f8
12 changed files with 164 additions and 144 deletions

View File

@ -19,15 +19,18 @@ jobs:
registry: gitea.jde.nz
username: DoesntMatter
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
- name: Build Base
- name: Build Base - Multiple Architectures
run: |
cd build-base && ./build.sh
- name: Build
- name: Build Test Applications
run: |
./build.sh
- name: Test
cd tests && ./build.sh
- name: Run Tests
run: |
./test.sh
- name: Publish
cd tests && ./test.sh
- name: Publish as Latest
run: |
SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} DOCKER_PUSH_TOKEN=${{ secrets.DOCKER_PUSH_TOKEN }} ./publish.sh
cd build-base && \
SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} \
DOCKER_PUSH_TOKEN=${{ secrets.DOCKER_PUSH_TOKEN }} \
./publish.sh

View File

@ -21,13 +21,6 @@ cd build-base
```
This creates the `gitea.jde.nz/public/dropshell-build-base:latest` Docker image for your current architecture and loads it into Docker.
For multiarch build (without loading):
```bash
cd build-base
BUILD_MODE=multiarch ./build.sh
```
This builds for linux/amd64 and linux/arm64 but keeps the image in the buildx cache only.
### Building a Project
```bash
./build.sh

View File

@ -200,7 +200,6 @@ RUN curl -LO https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSIO
#ARG DROGON_VERSION=1.9.5
WORKDIR /tmp
RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git /tmp/drogon && \
#RUN git clone --branch v${DROGON_VERSION} --depth 1 https://github.com/drogonframework/drogon.git /tmp/drogon && \
mkdir -p /tmp/drogon/build && \
cd /tmp/drogon/build && \
cmake .. \

View File

@ -5,22 +5,14 @@ set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Create buildx builder if it doesn't exist
docker buildx create --name multiarch --use 2>/dev/null || docker buildx use multiarch
docker buildx create --name multiarch --use \
--driver-opt env.BUILDKIT_MAX_PARALLELISM=4 \
2>/dev/null || docker buildx use multiarch
# Detect if we're building for testing or publishing
if [ "${BUILD_MODE:-test}" = "multiarch" ]; then
# Build multi-platform image (for publishing)
# Build multi-platform image and push it
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t "gitea.jde.nz/public/dropshell-build-base:latest" \
--push \
-t "gitea.jde.nz/public/dropshell-build-base:test" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build-base" \
${SCRIPT_DIR}
else
# Build single-platform image for current architecture and load it
docker buildx build \
--load \
-t "gitea.jde.nz/public/dropshell-build-base:latest" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build-base" \
${SCRIPT_DIR}
fi

23
build-base/publish.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail
# check standard variables present.
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
[[ -n $DOCKER_PUSH_TOKEN ]] || die "DOCKER_PUSH_TOKEN not specified"
echo "Publishing dropshell-build-base:test as :latest..."
# Pull the multiarch manifest from :test tag
docker buildx imagetools create \
--tag gitea.jde.nz/public/dropshell-build-base:latest \
gitea.jde.nz/public/dropshell-build-base:test
echo "Successfully tagged dropshell-build-base:test as :latest"
# Show the manifest to confirm it's multiarch
echo ""
echo "Verifying multiarch manifest:"
docker buildx imagetools inspect gitea.jde.nz/public/dropshell-build-base:latest

View File

@ -1,57 +0,0 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
export CMAKE_BUILD_TYPE="Debug"
rm -rf "${SCRIPT_DIR}/output"
mkdir -p "${SCRIPT_DIR}/output"
# If PROJECT is set, build only that project
if [ -n "${PROJECT:-}" ]; then
docker 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" \
"${SCRIPT_DIR}/tests/${PROJECT}"
else
# Build all projects
PROJECT="ipdemo"
docker 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" \
"${SCRIPT_DIR}/tests/${PROJECT}"
# Test aarch64 build of ipdemo
echo "Building ipdemo for aarch64..."
PROJECT="ipdemo"
docker buildx build \
--platform linux/arm64 \
-t "gitea.jde.nz/public/ipdemo-build:aarch64" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \
--build-arg CMAKE_BUILD_TYPE="Debug" \
--output "${SCRIPT_DIR}/output/aarch64" \
"${SCRIPT_DIR}/tests/${PROJECT}"
PROJECT="test_libs"
docker 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" \
"${SCRIPT_DIR}/tests/${PROJECT}"
fi

View File

@ -1,46 +0,0 @@
#!/bin/bash
set -euo pipefail
die() {
echo "Fatal error:"
echo "$1"
exit 1
}
# check the variables are present
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
[[ -n $DOCKER_PUSH_TOKEN ]] || die "DOCKER_PUSH_TOKEN not specified"
# Publish gitea.jde.nz/public/dropshell-build-base:latest
# login to registry handled by gitea workflow, otherwise asssume handled manually.
#docker login -u "anything" -p "${DOCKER_PUSH_TOKEN}" gitea.jde.nz
# Build and push the multi-platform image
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t "gitea.jde.nz/public/dropshell-build-base:latest" \
-f "build-base/Dockerfile.dropshell-build-base" \
--push \
build-base/
#SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# # download the sos binary
# SOS="${SCRIPT_DIR}/temp/sos"
# mkdir -p "${SCRIPT_DIR}/temp"
# trap 'rm -rf "${SCRIPT_DIR}/temp"' EXIT
# curl -L -o "${SOS}" https://getbin.xyz/sos
# chmod +x "${SOS}"
# # upload the dropshell-build script
# "${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/Dockerfile.dropshell-build" "Dockerfile.dropshell-build:latest"
echo "Done"

View File

@ -1,4 +1,5 @@
FROM gitea.jde.nz/public/dropshell-build-base:latest AS builder
ARG IMAGE_TAG
FROM gitea.jde.nz/public/dropshell-build-base:test AS builder
ARG PROJECT
ARG CMAKE_BUILD_TYPE=Debug

58
tests/build.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
#make canonical
ROOT_DIR="$(cd "${SCRIPT_DIR}/../" &> /dev/null && pwd)"
export CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Debug}"
# Function to build a project
build_project() {
local project="$1"
local platform="${2:-}"
local build_cmd
local tag
local output_dir
if [ -n "${platform}" ]; then
build_cmd=(docker buildx build "--platform" "${platform}")
local tag_suffix="${platform##*/}" # Extract arch from platform (e.g., linux/arm64 -> arm64)
tag="gitea.jde.nz/public/${project}-build-${tag_suffix}:test"
output_dir="${SCRIPT_DIR}/output/${tag_suffix}"
else
build_cmd=(docker build)
tag="gitea.jde.nz/public/${project}-build:test"
output_dir="${SCRIPT_DIR}/output/native"
fi
mkdir -p "${output_dir}"
"${build_cmd[@]}" \
-t "${tag}" \
-f "${SCRIPT_DIR}/Dockerfile.test-build" \
--build-arg PROJECT="${project}" \
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
--output "${output_dir}" \
"${SCRIPT_DIR}/${project}"
}
# Clean and prepare output directory
rm -rf "${SCRIPT_DIR}/output"
mkdir -p "${SCRIPT_DIR}/output"
# Build all projects
echo "Building ipdemo..."
build_project "ipdemo"
echo "Building ipdemo for aarch64..."
build_project "ipdemo" "linux/arm64"
echo "Building test_libs..."
build_project "test_libs"

19
tests/clear-cache.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
echo "Clearing Docker build cache..."
# Clear the build cache
docker builder prune -af
# Optional: Also clear dangling images and containers
echo "Cleaning up dangling images and stopped containers..."
docker system prune -f
echo "Build cache cleared successfully!"
# Show disk usage after cleanup
echo ""
echo "Docker disk usage after cleanup:"
docker system df

View File

@ -29,7 +29,42 @@ target_include_directories(${PROJECT_NAME} PRIVATE
# Find packages
set(CMAKE_PREFIX_PATH /usr/local)
find_package(OpenSSL REQUIRED)
# Find OpenSSL libraries in multiple possible locations
find_library(OPENSSL_SSL_LIB
NAMES ssl libssl libssl.a
PATHS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64
NO_DEFAULT_PATH
)
find_library(OPENSSL_CRYPTO_LIB
NAMES crypto libcrypto libcrypto.a
PATHS /usr/local/lib /usr/local/lib64 /usr/lib /usr/lib64
NO_DEFAULT_PATH
)
if(NOT OPENSSL_SSL_LIB OR NOT OPENSSL_CRYPTO_LIB)
message(FATAL_ERROR "Could not find OpenSSL libraries. SSL: ${OPENSSL_SSL_LIB}, Crypto: ${OPENSSL_CRYPTO_LIB}")
endif()
# Manually create OpenSSL targets for cross-compilation
if(NOT TARGET OpenSSL::Crypto)
add_library(OpenSSL::Crypto STATIC IMPORTED)
set_target_properties(OpenSSL::Crypto PROPERTIES
IMPORTED_LOCATION ${OPENSSL_CRYPTO_LIB}
INTERFACE_INCLUDE_DIRECTORIES /usr/local/include
)
endif()
if(NOT TARGET OpenSSL::SSL)
add_library(OpenSSL::SSL STATIC IMPORTED)
set_target_properties(OpenSSL::SSL PROPERTIES
IMPORTED_LOCATION ${OPENSSL_SSL_LIB}
INTERFACE_INCLUDE_DIRECTORIES /usr/local/include
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto
)
endif()
find_package(Drogon CONFIG REQUIRED)
find_package(nlohmann_json REQUIRED)

View File

@ -8,9 +8,9 @@ echo ""
echo "testing test_libs..."
# Run test_libs
if [ -f "${SCRIPT_DIR}/output/test_libs" ]; then
if [ -f "${SCRIPT_DIR}/output/native/test_libs" ]; then
echo "Running test_libs..."
"${SCRIPT_DIR}/output/test_libs"
"${SCRIPT_DIR}/output/native/test_libs"
echo "test_libs completed successfully!"
else
echo "test_libs binary not found"
@ -21,9 +21,9 @@ echo ""
echo "Testing ipdemo..."
# Check if ipdemo exists
if [ -f "${SCRIPT_DIR}/output/ipdemo" ]; then
if [ -f "${SCRIPT_DIR}/output/native/ipdemo" ]; then
echo "Running ipdemo..."
"${SCRIPT_DIR}/output/ipdemo" || echo "ipdemo test completed!"
"${SCRIPT_DIR}/output/native/ipdemo" || echo "ipdemo test completed!"
else
echo "ipdemo binary not found - run ./build.sh first"
fi
@ -32,10 +32,10 @@ echo ""
echo "Testing cross-architecture builds..."
# Verify the binary was built and check its architecture
if [ -f "${SCRIPT_DIR}/output/aarch64/ipdemo" ]; then
if [ -f "${SCRIPT_DIR}/output/arm64/ipdemo" ]; then
echo "aarch64 ipdemo binary built successfully!"
echo "Architecture info:"
file "${SCRIPT_DIR}/output/aarch64/ipdemo" || true
file "${SCRIPT_DIR}/output/arm64/ipdemo" || true
else
echo "aarch64 ipdemo binary not found"
fi