This commit is contained in:
parent
e4d0661d50
commit
1ac00e83f8
@ -19,15 +19,18 @@ jobs:
|
|||||||
registry: gitea.jde.nz
|
registry: gitea.jde.nz
|
||||||
username: DoesntMatter
|
username: DoesntMatter
|
||||||
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
password: ${{ secrets.DOCKER_PUSH_TOKEN }}
|
||||||
- name: Build Base
|
- name: Build Base - Multiple Architectures
|
||||||
run: |
|
run: |
|
||||||
cd build-base && ./build.sh
|
cd build-base && ./build.sh
|
||||||
- name: Build
|
- name: Build Test Applications
|
||||||
run: |
|
run: |
|
||||||
./build.sh
|
cd tests && ./build.sh
|
||||||
- name: Test
|
- name: Run Tests
|
||||||
run: |
|
run: |
|
||||||
./test.sh
|
cd tests && ./test.sh
|
||||||
- name: Publish
|
- name: Publish as Latest
|
||||||
run: |
|
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
|
||||||
|
@ -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.
|
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
|
### Building a Project
|
||||||
```bash
|
```bash
|
||||||
./build.sh
|
./build.sh
|
||||||
|
@ -200,7 +200,6 @@ RUN curl -LO https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSIO
|
|||||||
#ARG DROGON_VERSION=1.9.5
|
#ARG DROGON_VERSION=1.9.5
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git /tmp/drogon && \
|
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 && \
|
mkdir -p /tmp/drogon/build && \
|
||||||
cd /tmp/drogon/build && \
|
cd /tmp/drogon/build && \
|
||||||
cmake .. \
|
cmake .. \
|
||||||
|
@ -5,22 +5,14 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
# Create buildx builder if it doesn't exist
|
# 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
|
# Build multi-platform image and push it
|
||||||
if [ "${BUILD_MODE:-test}" = "multiarch" ]; then
|
docker buildx build \
|
||||||
# Build multi-platform image (for publishing)
|
--platform linux/amd64,linux/arm64 \
|
||||||
docker buildx build \
|
--push \
|
||||||
--platform linux/amd64,linux/arm64 \
|
-t "gitea.jde.nz/public/dropshell-build-base:test" \
|
||||||
-t "gitea.jde.nz/public/dropshell-build-base:latest" \
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build-base" \
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build-base" \
|
${SCRIPT_DIR}
|
||||||
${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
23
build-base/publish.sh
Executable 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
|
||||||
|
|
57
build.sh
57
build.sh
@ -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
|
|
||||||
|
|
46
publish.sh
46
publish.sh
@ -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"
|
|
@ -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 PROJECT
|
||||||
ARG CMAKE_BUILD_TYPE=Debug
|
ARG CMAKE_BUILD_TYPE=Debug
|
58
tests/build.sh
Executable file
58
tests/build.sh
Executable 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
19
tests/clear-cache.sh
Executable 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
|
@ -29,7 +29,42 @@ target_include_directories(${PROJECT_NAME} PRIVATE
|
|||||||
|
|
||||||
# Find packages
|
# Find packages
|
||||||
set(CMAKE_PREFIX_PATH /usr/local)
|
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(Drogon CONFIG REQUIRED)
|
||||||
find_package(nlohmann_json REQUIRED)
|
find_package(nlohmann_json REQUIRED)
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ echo ""
|
|||||||
echo "testing test_libs..."
|
echo "testing test_libs..."
|
||||||
|
|
||||||
# Run 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..."
|
echo "Running test_libs..."
|
||||||
"${SCRIPT_DIR}/output/test_libs"
|
"${SCRIPT_DIR}/output/native/test_libs"
|
||||||
echo "test_libs completed successfully!"
|
echo "test_libs completed successfully!"
|
||||||
else
|
else
|
||||||
echo "test_libs binary not found"
|
echo "test_libs binary not found"
|
||||||
@ -21,9 +21,9 @@ echo ""
|
|||||||
echo "Testing ipdemo..."
|
echo "Testing ipdemo..."
|
||||||
|
|
||||||
# Check if ipdemo exists
|
# Check if ipdemo exists
|
||||||
if [ -f "${SCRIPT_DIR}/output/ipdemo" ]; then
|
if [ -f "${SCRIPT_DIR}/output/native/ipdemo" ]; then
|
||||||
echo "Running ipdemo..."
|
echo "Running ipdemo..."
|
||||||
"${SCRIPT_DIR}/output/ipdemo" || echo "ipdemo test completed!"
|
"${SCRIPT_DIR}/output/native/ipdemo" || echo "ipdemo test completed!"
|
||||||
else
|
else
|
||||||
echo "ipdemo binary not found - run ./build.sh first"
|
echo "ipdemo binary not found - run ./build.sh first"
|
||||||
fi
|
fi
|
||||||
@ -32,10 +32,10 @@ echo ""
|
|||||||
echo "Testing cross-architecture builds..."
|
echo "Testing cross-architecture builds..."
|
||||||
|
|
||||||
# Verify the binary was built and check its architecture
|
# 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 "aarch64 ipdemo binary built successfully!"
|
||||||
echo "Architecture info:"
|
echo "Architecture info:"
|
||||||
file "${SCRIPT_DIR}/output/aarch64/ipdemo" || true
|
file "${SCRIPT_DIR}/output/arm64/ipdemo" || true
|
||||||
else
|
else
|
||||||
echo "aarch64 ipdemo binary not found"
|
echo "aarch64 ipdemo binary not found"
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user