Your Name f7adf6ce6d
All checks were successful
dropshell-build multiarch / build (linux/amd64) (push) Successful in 19s
dropshell-build multiarch / build (linux/arm64) (push) Successful in 27s
dropshell-build multiarch / create-manifest (push) Successful in 13s
docs: Update 2 files
2025-06-29 18:37:40 +12:00
2025-06-15 14:29:42 +12:00
2025-06-29 15:56:23 +12:00
2025-06-29 18:21:20 +12:00
2025-06-29 18:37:40 +12:00
2025-06-02 21:56:37 +12:00
2025-06-15 08:59:00 +12:00
2025-06-14 22:07:46 +12:00
2025-06-29 18:37:40 +12:00

Dropshell Build

A Docker-based build system for creating statically-linked C++ executables using Alpine Linux and musl libc.

Overview

This repository provides a comprehensive C++ development environment with:

  1. dropshell-build-base: A base image with C++ toolchain and libraries
  2. dropshell-build: Multi-stage Docker build system for C++ projects
  3. Test projects: Sample applications demonstrating the build system

Features

Libraries Available

The base image includes statically-linked versions of:

  • Web Framework: Drogon with async HTTP capabilities
  • Database Support: PostgreSQL (libpq), MySQL/MariaDB, SQLite3
  • HTTP Clients:
    • Custom Drogon-based HTTP utilities (see ipdemo)
    • CPR (C++ Requests) library for simplified HTTP requests
  • Networking: cURL, c-ares, OpenSSL
  • JSON: nlohmann/json, jsoncpp
  • Compression: zlib, zstd, lzma
  • Logging: spdlog, fmt
  • Utilities: ccache, mold linker

HTTP Client Options

Two HTTP client approaches are available:

  1. Drogon HTTP Utilities (see tests/ipdemo/src/http_utils.hpp):

    auto response = http_get("example.com", "/api/endpoint", true, 10.0);
    if (response.success && response.status_code == 200) {
        std::cout << response.body << std::endl;
    }
    
  2. CPR Library (C++ Requests):

    #include <cpr/cpr.h>
    cpr::Response r = cpr::Get(cpr::Url{"https://example.com/api"});
    if (r.status_code == 200) {
        std::cout << r.text << std::endl;
    }
    

    To use CPR in your CMakeLists.txt with proper static linking:

    find_package(nlohmann_json REQUIRED)
    
    # Find OpenSSL libraries (path varies by architecture)
    find_library(OPENSSL_SSL_LIB NAMES ssl PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
    find_library(OPENSSL_CRYPTO_LIB NAMES crypto PATHS /usr/local/lib64 /usr/local/lib NO_DEFAULT_PATH)
    
    # CPR static linking setup
    add_library(cpr::cpr_static STATIC IMPORTED)
    set_target_properties(cpr::cpr_static PROPERTIES
        IMPORTED_LOCATION "/usr/local/lib/libcpr.a"
        INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include"
        INTERFACE_LINK_LIBRARIES "/usr/local/lib/libcurl.a;${OPENSSL_SSL_LIB};${OPENSSL_CRYPTO_LIB};/usr/lib/libz.a;/usr/lib/libzstd.a;lzma;dl"
    )
    
    target_link_libraries(${PROJECT_NAME} PRIVATE 
        nlohmann_json::nlohmann_json 
        cpr::cpr_static)
    

Quick Start

Building the Base Image

cd build-base
./build.sh

Building a Project

./build.sh

Testing

./test.sh

Project Structure

Test Projects

  • ipdemo: Demonstrates Drogon HTTP utilities and JSON processing
  • test_libs: Tests all available libraries (fmt, spdlog, SQLite3, etc.)
  • cprdemo: Example using CPR library for HTTP requests

Environment Variables

  • CMAKE_BUILD_TYPE: "Debug" or "Release" (default: Debug)
  • PROJECT: Project name to build (default: ipdemo)

Installation

Description
Docker image and build script for cross-platform building of static musl c++ programs, with cmake.
Readme 639 MiB
Languages
C++ 97.5%
CMake 1.3%
Shell 1.2%