Files
dropshell-build/README.md
Your Name a8d4b43039
Some checks failed
dropshell-build multiarch / build (linux/amd64) (push) Successful in 4m48s
dropshell-build multiarch / build (linux/arm64) (push) Failing after 10m55s
dropshell-build multiarch / create-manifest (push) Has been skipped
docs: Update 3 files
2025-06-29 18:21:20 +12:00

2.7 KiB

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)
    
    # 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;/usr/local/lib64/libssl.a;/usr/local/lib64/libcrypto.a;/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