Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on:
on:
push:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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: |
Expand All @@ -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
Expand Down
10 changes: 8 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

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)
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
26 changes: 21 additions & 5 deletions build-generic-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
Loading