From 35a4670e8fc5b6e4100f13247b5a8a57dce8a2c6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 6 Jun 2025 19:47:15 +1200 Subject: [PATCH] 'Generic Commit' --- Dockerfile.dropshell-build | 3 +- build-base/Dockerfile.dropshell-build-base | 133 +++++++++++++++++++++ build-base/build.sh | 11 ++ 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 build-base/Dockerfile.dropshell-build-base create mode 100755 build-base/build.sh diff --git a/Dockerfile.dropshell-build b/Dockerfile.dropshell-build index 552ad6b..ec144cb 100644 --- a/Dockerfile.dropshell-build +++ b/Dockerfile.dropshell-build @@ -93,12 +93,13 @@ WORKDIR /tmp RUN curl -LO https://ftp.postgresql.org/pub/source/v${POSTGRES_VERSION}/postgresql-${POSTGRES_VERSION}.tar.gz && \ tar xzf postgresql-${POSTGRES_VERSION}.tar.gz && \ cd postgresql-${POSTGRES_VERSION} && \ - ./configure --prefix=/usr/local/pgsql --without-readline --without-zlib --enable-static --disable-shared && \ + ./configure --prefix=/usr/local/pgsql --without-readline --without-zlib --without-icu --enable-static --disable-shared && \ cd src/interfaces/libpq && \ make -j$(nproc) && \ make install && \ cd / && rm -rf /tmp/postgresql-${POSTGRES_VERSION} /tmp/postgresql-${POSTGRES_VERSION}.tar.gz +RUN ls /usr/local/include/pgsql/pg_config.h #ARG DROGON_VERSION=1.9.5 RUN git clone --recurse-submodules https://github.com/drogonframework/drogon.git /tmp/drogon && \ diff --git a/build-base/Dockerfile.dropshell-build-base b/build-base/Dockerfile.dropshell-build-base new file mode 100644 index 0000000..89bda64 --- /dev/null +++ b/build-base/Dockerfile.dropshell-build-base @@ -0,0 +1,133 @@ +FROM alpine:latest AS builder + +# Install ccache along with other dependencies +RUN apk add --no-cache \ + build-base \ + cmake \ + git \ + musl-dev \ + curl \ + bash \ + musl \ + g++ \ + ninja \ + linux-headers \ + mold \ + zlib-static \ + ccache \ + pkgconf \ + pkgconfig \ + libunwind \ + libunwind-dev \ + libunwind-static \ + zlib-dev \ + zlib-static \ + xz \ + xz-dev \ + xz-static \ + xz-libs \ + libdwarf \ + libdwarf-dev \ + elfutils \ + elfutils-dev \ + elfutils-libelf \ + binutils \ + binutils-dev \ + pipx \ + openssl-dev \ + sqlite-dev \ + libpq-dev \ + mariadb-connector-c-dev \ + ninja \ + util-linux-dev \ + util-linux-static \ + perl + +#RUN apk add --no-cache --update --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev + +SHELL ["/bin/bash", "-c"] + + +ARG CARES_VERSION=1.34.5 +WORKDIR /tmp +RUN curl -LO https://github.com/c-ares/c-ares/releases/download/v${CARES_VERSION}/c-ares-${CARES_VERSION}.tar.gz && \ + tar zxvf c-ares-${CARES_VERSION}.tar.gz && \ + cd c-ares-${CARES_VERSION} && \ + ./configure --enable-static --disable-shared --prefix=/usr/local/cares && \ + make -j$(nproc) && \ + make install && \ + cd / && rm -rf /tmp/c-ares-${CARES_VERSION} /tmp/c-ares-${CARES_VERSION}.tar.gz + +# Build OpenSSL statically with musl +ARG OPENSSL_VERSION=3.3.0 +WORKDIR /tmp +RUN curl -LO https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz && \ + tar xzf openssl-${OPENSSL_VERSION}.tar.gz && \ + cd openssl-${OPENSSL_VERSION} && \ + ./Configure no-shared no-dso no-tests no-async linux-x86_64 \ + --prefix=/usr/local/openssl-musl \ + -static -fPIC && \ + make -j$(nproc) && \ + make install_sw && \ + cd / && rm -rf /tmp/openssl-${OPENSSL_VERSION} /tmp/openssl-${OPENSSL_VERSION}.tar.gz + +# Build jsoncpp statically with musl +ARG JSONCPP_VERSION=1.9.6 +WORKDIR /tmp +RUN curl -LO https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/${JSONCPP_VERSION}.tar.gz && \ + tar xzf ${JSONCPP_VERSION}.tar.gz && \ + cd jsoncpp-${JSONCPP_VERSION} && \ + mkdir build && cd build && \ + cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX=/usr/local/jsoncpp && \ + make -j$(nproc) && \ + make install && \ + cd / && rm -rf /tmp/jsoncpp-${JSONCPP_VERSION} /tmp/${JSONCPP_VERSION}.tar.gz + +RUN ls /usr/local/jsoncpp/include/json/version.h + +# Build libpq statically +ARG POSTGRES_VERSION=16.2 +WORKDIR /tmp +RUN curl -LO https://ftp.postgresql.org/pub/source/v${POSTGRES_VERSION}/postgresql-${POSTGRES_VERSION}.tar.gz && \ + tar xzf postgresql-${POSTGRES_VERSION}.tar.gz && \ + cd postgresql-${POSTGRES_VERSION} && \ + ./configure --prefix=/usr/local/pgsql --without-readline --without-zlib --without-icu --enable-static --disable-shared && \ + cd src/interfaces/libpq && \ + make -j$(nproc) && \ + make install && \ + cd / && rm -rf /tmp/postgresql-${POSTGRES_VERSION} /tmp/postgresql-${POSTGRES_VERSION}.tar.gz + +RUN ls /usr/local/include/pgsql/pg_config.h + +#ARG DROGON_VERSION=1.9.5 +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 && \ + cd /tmp/drogon/build && \ + cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DCMAKE_CXX_FLAGS="-static -static-libgcc -static-libstdc++" \ + -DCMAKE_EXE_LINKER_FLAGS="-static" \ + -DCMAKE_INSTALL_PREFIX=/usr/local \ + -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \ + -DUSE_MONGODB=OFF \ + -DUSE_POSTGRESQL=ON \ + -DUSE_MYSQL=ON \ + -DUSE_SQLITE3=ON \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_TESTING=OFF \ + -DUUID_LIBRARY=/usr/lib/libuuid.a \ + -DOPENSSL_ROOT_DIR=/usr/local/openssl-musl \ + -DOPENSSL_USE_STATIC_LIBS=TRUE \ + -DCARES_INCLUDE_DIR=/usr/local/cares/include \ + -DCARES_LIBRARY=/usr/local/cares/lib/libcares.a \ + -DJSONCPP_INCLUDE_DIRS=/usr/local/jsoncpp/include \ + -DJSONCPP_LIBRARIES=/usr/local/jsoncpp/lib/libjsoncpp.a \ + -DPostgreSQL_INCLUDE_DIR=/usr/local/pgsql/include \ + -DPostgreSQL_LIBRARY=/usr/local/pgsql/lib/libpq.a \ + &&\ + make -j$(nproc) && \ + make install && \ + cd / && rm -rf /tmp/drogon diff --git a/build-base/build.sh b/build-base/build.sh new file mode 100755 index 0000000..326b78e --- /dev/null +++ b/build-base/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +docker build \ + -t "gitea.jde.nz/public/dropshell-build-base:latest" \ + -f "${SCRIPT_DIR}/Dockerfile.dropshell-build-base" \ + ${SCRIPT_DIR} + \ No newline at end of file