diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95f47ca8..cd34db2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: +on: push: workflow_dispatch: inputs: @@ -43,7 +43,7 @@ jobs: uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: "mgconsole_ctest.log" - path: build/Testing/Temporary/LastTest.log + path: build/Testing/Temporary/LastTest.log build_windows_mingw: name: Build and test mgconsole on Windows @@ -200,9 +200,9 @@ jobs: run: | docker rmi $MEMGRAPH_IMAGE || true if [[ "${{ matrix.arch }}" == "X64" ]]; then - docker rmi memgraph/mgbuild:v7_centos-9 || true + docker rmi memgraph/mgbuild:v8_ubuntu-24.04 || true elif [[ "${{ matrix.arch }}" == "ARM64" ]]; then - docker rmi memgraph/mgbuild:v7_debian-12-arm || true + docker rmi memgraph/mgbuild:v8_ubuntu-24.04-arm || true fi docker_build_and_test: @@ -215,7 +215,7 @@ jobs: - name: Build and test mgconsole in Docker container run: | - docker build -t mgconsole . + docker build --build-arg GIT_REF=${{ github.sha }} -t mgconsole . - name: Run latest Memgraph Docker container run: | @@ -240,11 +240,11 @@ jobs: - name: Test mgconsole in Docker container run: | # Test pipe directly into docker run - echo "RETURN 1;" | docker run --network host mgconsole:latest + echo "RETURN 1;" | docker run --network host -i mgconsole:latest # Test entrypoint override with echo docker run --network host --rm --entrypoint sh mgconsole:latest -c "echo 'RETURN 1;' | mgconsole" - + - name: Cleanup docker images run: | docker rmi mgconsole || true diff --git a/CLAUDE.md b/CLAUDE.md index fcc67474..17109ea4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,8 +24,14 @@ The binary lands at `build/src/mgconsole`. `compile_commands.json` is emitted in `-Wall -Wextra -pedantic -Werror` is enabled — warnings break the build. **Static / release build** (matches what ships): `./build-generic-linux.sh` builds inside the -`memgraph/mgbuild` Docker image with the Memgraph toolchain and `-DMGCONSOLE_STATIC_SSL=ON`, -producing `build/generic/mgconsole`. +`memgraph/mgbuild:v8_ubuntu-24.04` image with the Memgraph toolchain and +`-DMGCONSOLE_STATIC_SSL=ON`, producing `build/generic/mgconsole`. It exports `CC`/`CXX` pointing +at `/opt/toolchain-v8/bin/{gcc,g++}` (configured `--with-sysroot`) plus +`OPENSSL_ROOT_DIR=/opt/toolchain-v8/sysroot/usr`, so everything — including the +`ExternalProject` deps, which inherit the environment but not CMake toolchain settings — links +against the toolchain's GLIBC 2.31 sysroot instead of the image's GLIBC 2.39. That's what keeps +the generic binary runnable on older distros; the script prints the maximum `GLIBC_*` version +the binary ends up referencing (currently 2.25). ## Test diff --git a/CMakeLists.txt b/CMakeLists.txt index a18d9083..935c52c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # along with this program. If not, see . cmake_minimum_required(VERSION 3.10) -project(mgconsole VERSION 1.7.0) +project(mgconsole VERSION 1.7.1) include(CTest) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) diff --git a/Dockerfile b/Dockerfile index 9e15873a..c9ba3870 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,19 +12,21 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* -RUN git clone https://github.com/memgraph/mgconsole.git /mgconsole +ARG GIT_REF=master + +RUN git clone https://github.com/memgraph/mgconsole.git /mgconsole && \ + git -C /mgconsole checkout --detach "$GIT_REF" WORKDIR /mgconsole -RUN mkdir build && cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release .. && \ - make && \ - make install +RUN cmake -B build -DCMAKE_BUILD_TYPE=Release . && \ + cmake --build build && \ + cmake --install build --strip FROM gcr.io/distroless/base-debian13:debug WORKDIR /mgconsole -COPY --from=builder /mgconsole/build/src/mgconsole /usr/local/bin/mgconsole +COPY --from=builder /bin/mgconsole /usr/local/bin/mgconsole ENTRYPOINT ["mgconsole"] diff --git a/build-generic-linux.sh b/build-generic-linux.sh index c12e5502..896a0fc1 100755 --- a/build-generic-linux.sh +++ b/build-generic-linux.sh @@ -22,11 +22,15 @@ function cleanup() { exit $status } -ARCH="$(arch)" +TOOLCHAIN_ROOT="/opt/toolchain-v8" +ARCH="$(uname -m)" if [[ $ARCH == "x86_64" ]]; then - DOCKER_IMAGE="memgraph/mgbuild:v7_centos-9" # libc 2.34 + DOCKER_IMAGE="memgraph/mgbuild:v8_ubuntu-24.04" elif [[ $ARCH == "aarch64" ]]; then - DOCKER_IMAGE="memgraph/mgbuild:v7_debian-12-arm" # libc 2.36 + DOCKER_IMAGE="memgraph/mgbuild:v8_ubuntu-24.04-arm" +else + echo -e "${RED}Unsupported architecture: $ARCH${RESET}" + exit 1 fi trap cleanup EXIT ERR @@ -38,13 +42,25 @@ echo -e "${GREEN}Copying mgconsole source code to build container...${RESET}" docker cp "$PROJECT_ROOT/." builder:/home/mg/mgconsole docker exec -u root builder bash -c "chown -R mg:mg /home/mg/mgconsole" +# Build against the toolchain sysroot (glibc 2.31) +# --strip on install: the sysroot gcc build carries debug info (~21MB -> ~8MB). echo -e "${GREEN}Building mgconsole...${RESET}" docker exec -u mg builder bash -c " - source /opt/toolchain-v7/activate && \ + source $TOOLCHAIN_ROOT/activate && \ + export CC=$TOOLCHAIN_ROOT/bin/gcc CXX=$TOOLCHAIN_ROOT/bin/g++ && \ + export OPENSSL_ROOT_DIR=$TOOLCHAIN_ROOT/sysroot/usr && \ cd /home/mg/mgconsole && \ cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DMGCONSOLE_STATIC_SSL=ON -DCMAKE_INSTALL_PREFIX=/home/mg/mgconsole/build/install . && \ cmake --build build && \ - cmake --install build" + cmake --install build --strip" + +echo -e "${GREEN}Checking GLIBC requirement of the binary...${RESET}" +docker exec -u mg builder bash -c ' + source '"$TOOLCHAIN_ROOT"'/activate + versions=$(objdump -T /home/mg/mgconsole/build/install/bin/mgconsole \ + | grep -oE "GLIBC_[0-9]+(\.[0-9]+)+" | sort -uV) + echo "Referenced GLIBC versions: $(echo $versions)" + echo "Maximum GLIBC version required: $(echo "$versions" | tail -n 1)"' echo -e "${GREEN}Saving build...${RESET}" mkdir -p "$PROJECT_ROOT/build/generic"