This commit is contained in:
parent
3fea581249
commit
1da19b9191
@ -1,8 +1,6 @@
|
|||||||
FROM --platform=$BUILDPLATFORM alpine:latest AS builder
|
FROM --platform=$BUILDPLATFORM alpine:latest AS builder
|
||||||
|
|
||||||
# Add build arguments for platform
|
ARG PROJECT
|
||||||
ARG TARGETPLATFORM
|
|
||||||
ARG BUILDPLATFORM
|
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
@ -16,7 +14,8 @@ RUN apk add --no-cache \
|
|||||||
g++ \
|
g++ \
|
||||||
ninja \
|
ninja \
|
||||||
linux-headers \
|
linux-headers \
|
||||||
mold
|
mold \
|
||||||
|
zlib-static
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
@ -29,11 +28,17 @@ RUN mkdir -p build_static && \
|
|||||||
cmake -G Ninja -B build_static -DCMAKE_BUILD_TYPE=Release \
|
cmake -G Ninja -B build_static -DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
-DCMAKE_EXE_LINKER_FLAGS="-static" \
|
||||||
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
|
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
|
||||||
|
-DZLIB_BUILD_SHARED=OFF \
|
||||||
|
-DZLIB_BUILD_STATIC=ON \
|
||||||
-DBUILD_SHARED_LIBS=OFF \
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DPROJECT_NAME="${PROJECT}" \
|
||||||
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
||||||
|
|
||||||
RUN cmake --build build_static
|
RUN cmake --build build_static
|
||||||
|
|
||||||
# Final stage that only contains the binary
|
# Final stage that only contains the binary
|
||||||
FROM scratch AS $PROJECT
|
FROM scratch AS project
|
||||||
COPY --from=builder /build/build_static/$PROJECT /$PROJECT
|
|
||||||
|
ARG PROJECT
|
||||||
|
|
||||||
|
COPY --from=builder /build/build_static/${PROJECT} /${PROJECT}
|
16
build.sh
16
build.sh
@ -3,9 +3,19 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
PROJECT="ipdemo" # Define your project name here
|
||||||
|
|
||||||
rm -rf "${SCRIPT_DIR}/src/build"
|
mkdir -p "${SCRIPT_DIR}/output"
|
||||||
rm -rf "${SCRIPT_DIR}/src/build.*"
|
|
||||||
|
|
||||||
docker build -t gitea.jde.nz/public/dropshell-build:test -f "${SCRIPT_DIR}/Dockerfile" "${SCRIPT_DIR}"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
|
|
||||||
|
rm -rf "${SCRIPT_DIR}/output"
|
||||||
|
mkdir -p "${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
||||||
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||||
|
--build-arg PROJECT="${PROJECT}" \
|
||||||
|
--output "${SCRIPT_DIR}/output" \
|
||||||
|
"${SCRIPT_DIR}/${PROJECT}"
|
||||||
|
|
||||||
|
@ -6,8 +6,12 @@ execute_process(
|
|||||||
)
|
)
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
get_filename_component(PROJECT_EXE_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
|
if(NOT DEFINED PROJECT_NAME)
|
||||||
project(${PROJECT_EXE_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
message(FATAL_ERROR "PROJECT_NAME is not defined. Pass it via -DPROJECT_NAME=<name>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
||||||
|
set(PROJECT_EXE_NAME ${PROJECT_NAME})
|
||||||
|
|
||||||
# Force static linking globally
|
# Force static linking globally
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
||||||
@ -64,6 +68,32 @@ target_include_directories(${PROJECT_EXE_NAME} PRIVATE
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Configure libassert
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
libassert
|
||||||
|
GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert.git
|
||||||
|
GIT_TAG v2.1.5
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(libassert)
|
||||||
|
|
||||||
|
# Add cpptrace
|
||||||
|
FetchContent_Declare(
|
||||||
|
cpptrace
|
||||||
|
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
|
||||||
|
GIT_TAG v0.8.3
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(cpptrace)
|
||||||
|
|
||||||
|
# Add nlohmann/json
|
||||||
|
FetchContent_Declare(
|
||||||
|
nlohmann_json
|
||||||
|
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||||
|
GIT_TAG v3.12.0
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(nlohmann_json)
|
||||||
|
|
||||||
# Link libraries
|
# Link libraries
|
||||||
target_link_libraries(${PROJECT_EXE_NAME} PRIVATE
|
target_link_libraries(${PROJECT_EXE_NAME} PRIVATE
|
||||||
libassert::assert
|
libassert::assert
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
||||||
|
|
||||||
function upload_file() {
|
|
||||||
local file="$1"
|
|
||||||
local server="getbin.xyz"
|
|
||||||
local tag="latest"
|
|
||||||
local name;
|
|
||||||
name=$(basename "${file}")
|
|
||||||
|
|
||||||
# upload the file to the server
|
|
||||||
echo "Uploading ${file} to the server"
|
|
||||||
sos upload "${server}" "${file}" "${name}:${tag}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ! command -v sos &> /dev/null ; then
|
|
||||||
echo "sos could not be found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# find all .tgz in this directory
|
|
||||||
for file in "${SCRIPT_DIR}"/*.tgz; do
|
|
||||||
# upload the file to the server
|
|
||||||
echo "Uploading ${file} to the server"
|
|
||||||
upload_file "${file}"
|
|
||||||
done
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
publish.sh
18
publish.sh
@ -7,26 +7,12 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|||||||
# download the sos binary
|
# download the sos binary
|
||||||
SOS="${SCRIPT_DIR}/temp/sos"
|
SOS="${SCRIPT_DIR}/temp/sos"
|
||||||
mkdir -p "${SCRIPT_DIR}/temp"
|
mkdir -p "${SCRIPT_DIR}/temp"
|
||||||
|
trap 'rm -rf "${SCRIPT_DIR}/temp"' EXIT
|
||||||
|
|
||||||
curl -L -o "${SOS}" https://getbin.xyz/sos
|
curl -L -o "${SOS}" https://getbin.xyz/sos
|
||||||
chmod +x "${SOS}"
|
chmod +x "${SOS}"
|
||||||
|
|
||||||
|
|
||||||
# upload the dropshell-build script
|
# upload the dropshell-build script
|
||||||
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/src/dropshell-build" "dropshell-build:latest"
|
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/Dockerfile.dropshell-build" "Dockerfile.dropshell-build:latest"
|
||||||
|
|
||||||
# upload the install requirements script
|
|
||||||
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/src/dropshell-build-install-requirements" "dropshell-build-install-requirements:latest"
|
|
||||||
|
|
||||||
|
|
||||||
# tag and push the dropshell-build image
|
|
||||||
echo "Tagging and pushing the dropshell-build image"
|
|
||||||
|
|
||||||
docker tag gitea.jde.nz/public/dropshell-build:test gitea.jde.nz/public/dropshell-build:latest
|
|
||||||
|
|
||||||
docker push gitea.jde.nz/public/dropshell-build:latest
|
|
||||||
|
|
||||||
|
|
||||||
# clean up
|
|
||||||
rm -rf "${SCRIPT_DIR}/temp"
|
|
||||||
echo "Done"
|
echo "Done"
|
8
test.sh
8
test.sh
@ -4,13 +4,13 @@ set -euo pipefail
|
|||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
echo "Testing dropshell-build"
|
echo "Testing"
|
||||||
|
|
||||||
rm -rf "${SCRIPT_DIR}/ipdemo/build"
|
"${SCRIPT_DIR}/build.sh"
|
||||||
|
|
||||||
DROPSHELL_BUILD_TAG="test" "${SCRIPT_DIR}/src/dropshell-build" -r -m "${SCRIPT_DIR}/ipdemo"
|
[ -f "${SCRIPT_DIR}/output/ipdemo" ] || { echo "ipdemo binary not found"; exit 1; }
|
||||||
|
|
||||||
"${SCRIPT_DIR}/ipdemo/output/ipdemo.x86_64"
|
"${SCRIPT_DIR}/output/ipdemo"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user