Use Ninja for build

Also adjust caching in some places.
This commit is contained in:
Corey 2025-05-01 17:01:53 -04:00
parent 48d87f667d
commit 42ce91d8e5
Signed by: coco
GPG Key ID: 051138DA6AEE3E60
3 changed files with 17 additions and 18 deletions

View File

@ -23,6 +23,7 @@ RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
mariadb-connector-c \ mariadb-connector-c \
openssl \ openssl \
python3 \ python3 \
tzdata \
zeromq \ zeromq \
zlib zlib
@ -35,8 +36,7 @@ ENV PATH=/xiadmin/.local/bin:$PATH
FROM base AS build FROM base AS build
# Install build dependencies. # Install build dependencies.
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \ RUN apk --update-cache add \
apk --update-cache add \
binutils-dev \ binutils-dev \
ccache \ ccache \
cmake \ cmake \
@ -48,6 +48,7 @@ RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
openssl-dev \ openssl-dev \
python3-dev \ python3-dev \
py3-pip \ py3-pip \
samurai \
zeromq-dev \ zeromq-dev \
zlib-dev zlib-dev
@ -56,7 +57,7 @@ WORKDIR /server
# Install Python dependencies here, copied into runtime stage. # Install Python dependencies here, copied into runtime stage.
RUN --mount=type=bind,source=server/tools/requirements.txt,target=/tmp/requirements.txt \ RUN --mount=type=bind,source=server/tools/requirements.txt,target=/tmp/requirements.txt \
--mount=type=cache,target=/xiadmin/.cache/pip,uid=$UID,gid=$GID \ --mount=type=cache,target=/xiadmin/.cache/pip,id=pip-alpine,uid=$UID,gid=$GID \
pip3 install --break-system-packages --user --ignore-installed --requirement /tmp/requirements.txt pip3 install --break-system-packages --user --ignore-installed --requirement /tmp/requirements.txt
# Exclude changes to git metadata, scripts, and sql not needed for build. # Exclude changes to git metadata, scripts, and sql not needed for build.
@ -80,8 +81,8 @@ RUN LSB_FILE="/server/cmake/FindMariaDBCPP.cmake" && \
# Cache the build. Bind mounts to save copy time and keep clean git hash. # Cache the build. Bind mounts to save copy time and keep clean git hash.
ENV CCACHE_DIR=/xiadmin/.ccache ENV CCACHE_DIR=/xiadmin/.ccache
RUN --mount=type=cache,target=/xiadmin/build,uid=$UID,gid=$GID \ RUN --mount=type=cache,target=/xiadmin/build,id=build-alpine,uid=$UID,gid=$GID \
--mount=type=cache,target=/xiadmin/.ccache,uid=$UID,gid=$GID \ --mount=type=cache,target=/xiadmin/.ccache,id=ccache-alpine,uid=$UID,gid=$GID \
--mount=type=bind,source=.git,target=/.git \ --mount=type=bind,source=.git,target=/.git \
--mount=type=bind,source=server/.git,target=/server/.git \ --mount=type=bind,source=server/.git,target=/server/.git \
--mount=type=bind,source=server/scripts,target=/server/scripts \ --mount=type=bind,source=server/scripts,target=/server/scripts \
@ -90,9 +91,9 @@ RUN --mount=type=cache,target=/xiadmin/build,uid=$UID,gid=$GID \
cp -p /xiadmin/build/version.cpp /server/src/common/ 2> /dev/null; \ cp -p /xiadmin/build/version.cpp /server/src/common/ 2> /dev/null; \
cp -p /xiadmin/build/xi_* /server/ 2> /dev/null; \ cp -p /xiadmin/build/xi_* /server/ 2> /dev/null; \
# --- End --- # --- End ---
cmake -S /server -B /xiadmin/build -DCMAKE_BUILD_TYPE=Release && \ cmake -G Ninja -S /server -B /xiadmin/build -DCMAKE_BUILD_TYPE=Release && \
# --- PATCH efsw --- # --- PATCH efsw ---
EFSW_FILE="/xiadmin/build/_deps/efsw-src/src/efsw/FileWatcherInotify.cpp"; \ EFSW_FILE="/xiadmin/build/_deps/efsw-src/src/efsw/FileWatcherInotify.cpp" && \
if [ -f "$EFSW_FILE" ]; then \ if [ -f "$EFSW_FILE" ]; then \
# Check if include is missing. # Check if include is missing.
if ! grep -qF '#include <sys/select.h>' "$EFSW_FILE"; then \ if ! grep -qF '#include <sys/select.h>' "$EFSW_FILE"; then \
@ -110,9 +111,8 @@ RUN --mount=type=cache,target=/xiadmin/build,uid=$UID,gid=$GID \
# --- End Patch --- # --- End Patch ---
cmake --build /xiadmin/build -j$(nproc) && \ cmake --build /xiadmin/build -j$(nproc) && \
# --- CACHE --- # --- CACHE ---
# Alpine seems to always re-link the executables. cp -p /server/xi_* /xiadmin/build/ && \
cp -p /server/xi_* /xiadmin/build/; \ cp -p /server/src/common/version.cpp /xiadmin/build/
cp -p /server/src/common/version.cpp /xiadmin/build/;
# --- End --- # --- End ---
################# #################

View File

@ -30,6 +30,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
libzmq5 \ libzmq5 \
mariadb-client \ mariadb-client \
python3 \ python3 \
tzdata \
zlib1g zlib1g
RUN git config --system --add safe.directory /server RUN git config --system --add safe.directory /server
@ -41,20 +42,18 @@ ENV PATH=/xiadmin/.local/bin:$PATH
FROM base AS build FROM base AS build
# Install build dependencies. # Install build dependencies.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ RUN apt-get update && apt-get install --assume-yes --no-install-recommends --quiet \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install --assume-yes --no-install-recommends --quiet \
binutils-dev \ binutils-dev \
build-essential \ build-essential \
ccache \ ccache \
cmake \ cmake \
g++ \ g++ \
git \
libluajit-5.1-dev \ libluajit-5.1-dev \
libmariadb-dev-compat \ libmariadb-dev-compat \
libssl-dev \ libssl-dev \
libzmq3-dev \ libzmq3-dev \
make \ make \
ninja-build \
python3-dev \ python3-dev \
python3-pip \ python3-pip \
zlib1g-dev zlib1g-dev
@ -85,11 +84,11 @@ RUN --mount=type=cache,target=/xiadmin/build,uid=$UID,gid=$GID \
cp -p /xiadmin/build/version.cpp /server/src/common/ 2> /dev/null; \ cp -p /xiadmin/build/version.cpp /server/src/common/ 2> /dev/null; \
cp -p /xiadmin/build/xi_* /server/ 2> /dev/null; \ cp -p /xiadmin/build/xi_* /server/ 2> /dev/null; \
# --- End --- # --- End ---
cmake -S /server -B /xiadmin/build -DCMAKE_BUILD_TYPE=Release && \ cmake -G Ninja -S /server -B /xiadmin/build -DCMAKE_BUILD_TYPE=Release && \
cmake --build /xiadmin/build -j$(nproc) && \ cmake --build /xiadmin/build -j$(nproc) && \
# --- CACHE --- # --- CACHE ---
cp -p /server/xi_* /xiadmin/build/; \ cp -p /server/xi_* /xiadmin/build/ && \
cp -p /server/src/common/version.cpp /xiadmin/build/; cp -p /server/src/common/version.cpp /xiadmin/build/
# --- End --- # --- End ---
################# #################

View File

@ -27,7 +27,7 @@ fi
# Load environment variables. # Load environment variables.
if [ -f "$ENV_FILE" ]; then if [ -f "$ENV_FILE" ]; then
echo "Loading environment vairables from $ENV_FILE..." echo "Loading environment variables from $ENV_FILE..."
set -a # Automatically export all sourced variables. set -a # Automatically export all sourced variables.
source "$ENV_FILE" source "$ENV_FILE"
set +a set +a