From 82c99a3d55b2979476ef11b349d532e303b92ea7 Mon Sep 17 00:00:00 2001 From: j842 Date: Sat, 7 Jun 2025 14:57:00 +1200 Subject: [PATCH] Build MYSQL too, because why not --- build-base/CLAUDE.md | 62 ++++++++++++++++++++++ build-base/Dockerfile.dropshell-build-base | 28 ++++++++-- 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 build-base/CLAUDE.md diff --git a/build-base/CLAUDE.md b/build-base/CLAUDE.md new file mode 100644 index 0000000..407eb28 --- /dev/null +++ b/build-base/CLAUDE.md @@ -0,0 +1,62 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This repository contains the build configuration for `dropshell-build-base`, a Docker base image that provides a comprehensive C++ development environment specifically tailored for building applications with the Drogon web framework and multiple database backends. + +## Key Commands + +### Building the Docker Image +```bash +./build.sh +``` +This builds the Docker image and tags it as `gitea.jde.nz/public/dropshell-build-base:latest`. + +### Manual Docker Build +```bash +docker build -t gitea.jde.nz/public/dropshell-build-base:latest -f Dockerfile.dropshell-build-base . +``` + +## Architecture and Design + +### Purpose +This base image is designed to create statically-linked C++ executables using: +- Alpine Linux with musl libc for minimal container size +- All libraries built with static linking (`--enable-static --disable-shared`) +- Comprehensive database support (PostgreSQL, MySQL/MariaDB, SQLite3) +- Modern C++ web framework (Drogon) with async capabilities + +### Key Components Built from Source +1. **c-ares** (1.34.5) - Async DNS resolution +2. **OpenSSL** (3.3.0) - Built with musl, configured for static linking +3. **jsoncpp** (1.9.6) - JSON parsing +4. **PostgreSQL libpq** (16.2) - PostgreSQL client library +5. **cURL** (8.7.1) - HTTP client with OpenSSL support +6. **MariaDB Connector/C** (3.4.5) - MySQL/MariaDB client +7. **SQLite3** (3.45.0) - Embedded database +8. **MySQL client** (8.0.36) - MySQL client library +9. **Drogon** (latest from git) - C++ web framework + +### Build Characteristics +- All libraries installed in `/usr/local/` with specific prefixes +- Position Independent Code (`-fPIC`) enabled for static linking +- CMake configured to prefer static libraries (`.a` suffix) +- Drogon built with PostgreSQL, MySQL, and SQLite3 support enabled + +### Important Paths +- OpenSSL: `/usr/local/openssl-musl/` +- PostgreSQL: `/usr/local/pgsql/` +- MariaDB Connector: `/usr/local/mariadb-connector-c/` +- SQLite3: `/usr/local/sqlite3/` +- MySQL: `/usr/local/mysql/` +- jsoncpp: `/usr/local/jsoncpp/` +- c-ares: `/usr/local/cares/` +- cURL: `/usr/local/curl/` + +### Notes for Development +- When modifying the Dockerfile, maintain the build order as dependencies are interlinked +- The image uses the latest Drogon from git master, not a fixed version +- All database libraries are built before Drogon to ensure proper linking +- The build uses `make -j$(nproc)` for parallel compilation \ No newline at end of file diff --git a/build-base/Dockerfile.dropshell-build-base b/build-base/Dockerfile.dropshell-build-base index 78d9a01..030fdc6 100644 --- a/build-base/Dockerfile.dropshell-build-base +++ b/build-base/Dockerfile.dropshell-build-base @@ -23,7 +23,6 @@ RUN apk add --no-cache \ mold \ musl \ musl-dev \ - mysql-dev \ ncurses-dev \ ninja \ perl \ @@ -136,6 +135,29 @@ RUN wget https://www.sqlite.org/2024/sqlite-autoconf-3450000.tar.gz && \ make install && \ cd .. && rm -rf sqlite-autoconf-3450000* +# Build MySQL statically +ARG MYSQL_VERSION=8.0.36 +WORKDIR /tmp +RUN curl -LO https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-${MYSQL_VERSION}.tar.gz && \ + tar xzf mysql-${MYSQL_VERSION}.tar.gz && \ + cd mysql-${MYSQL_VERSION} && \ + cmake . \ + -DCMAKE_BUILD_TYPE=Release \ + -DWITH_SYSTEM_LIBS=OFF \ + -DWITH_UNIT_TESTS=OFF \ + -DWITH_EMBEDDED_SERVER=OFF \ + -DWITH_INNODB_MEMCACHED=OFF \ + -DWITH_SSL=system \ + -DWITH_ZLIB=system \ + -DWITH_LIBEVENT=system \ + -DWITH_SSL=/usr/local/openssl-musl \ + -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON && \ + make -j$(nproc) && \ + make install && \ + cd / && rm -rf /tmp/mysql-${MYSQL_VERSION} /tmp/mysql-${MYSQL_VERSION}.tar.gz + #ARG DROGON_VERSION=1.9.5 WORKDIR /tmp RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git /tmp/drogon && \ @@ -165,8 +187,8 @@ RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git -DJSONCPP_LIBRARIES=/usr/local/jsoncpp/lib/libjsoncpp.a \ -DPostgreSQL_INCLUDE_DIR=/usr/local/pgsql/include \ -DPostgreSQL_LIBRARY=/usr/local/pgsql/lib/libpq.a \ - -DMYSQL_INCLUDE_DIR=/usr/local/mariadb-connector-c/include \ - -DMYSQL_LIBRARIES=/usr/local/mariadb-connector-c/lib/mariadb/libmariadbclient.a \ + -DMYSQL_INCLUDE_DIR=/usr/local/mysql/include \ + -DMYSQL_LIBRARIES=/usr/local/mysql/lib/libmysqlclient.a \ -DSQLITE3_LIBRARY=/usr/local/sqlite3/lib/libsqlite3.a \ -DSQLITE3_INCLUDE_DIR=/usr/local/sqlite3/include \ -DSQLITE3_STATIC=ON \