fix: Build botserver inside container to match glibc target
Some checks failed
BotServer CI/CD / build (push) Failing after 1s

The CI runner (host) has glibc 2.41 but the prod container has glibc 2.36.
Building on the host causes GLIBC_2.38/2.39 not found errors when running
inside the container.

This change makes the CI build inside the container where the binary will
actually run, ensuring glibc compatibility.
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-02 13:46:12 -03:00
parent 7b4753af0d
commit 3b8acde6fb

View file

@ -7,11 +7,8 @@ on:
branches: ["main"] branches: ["main"]
env: env:
CARGO_BUILD_JOBS: 8 CARGO_BUILD_JOBS: 4
CARGO_NET_RETRY: 10 CARGO_NET_RETRY: 10
WORKSPACE: /opt/gbo/ci/botserver
CARGO_TARGET_DIR: /opt/gbo/ci/botserver/target
PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
jobs: jobs:
build: build:
@ -23,77 +20,86 @@ jobs:
git config --global http.sslVerify false git config --global http.sslVerify false
git config --global --add safe.directory "*" git config --global --add safe.directory "*"
- name: Setup Workspace - name: Setup Workspace inside container
run: | run: |
mkdir -p $WORKSPACE echo "=== Setting up workspace inside container ==="
cd $WORKSPACE ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "incus exec system -- bash -c '
# Update or clone botlib mkdir -p /opt/gbo/ci/botserver
cd /opt/gbo/ci/botserver
# Clone botlib
if [ -d botlib/.git ]; then if [ -d botlib/.git ]; then
git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD git -C botlib fetch --depth 1 origin main && git -C botlib checkout FETCH_HEAD
else else
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/botlib.git botlib
fi fi
# Update or clone botserver # Clone botserver
if [ -d botserver/.git ]; then if [ -d botserver/.git ]; then
git -C botserver fetch --depth 1 origin main && git -C botserver checkout FETCH_HEAD git -C botserver fetch --depth 1 origin main && git -C botserver checkout FETCH_HEAD
else else
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/BotServer.git botserver
fi fi
# Get workspace Cargo.toml from gb and strip unused members # Clone gb workspace and get Cargo.toml
git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws git clone --depth 1 --branch main https://alm.pragmatismo.com.br/GeneralBots/gb.git /tmp/gb-ws
cp /tmp/gb-ws/Cargo.toml Cargo.toml cp /tmp/gb-ws/Cargo.toml Cargo.toml
for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do for m in botapp botdevice bottest botui botbook botmodels botplugin bottemplates; do
grep -v "\"$m\"" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml grep -v \"\\\"$m\\\"\" Cargo.toml > /tmp/c.toml && mv /tmp/c.toml Cargo.toml
done done
rm -rf /tmp/gb-ws rm -rf /tmp/gb-ws
echo \"Workspace setup complete\"
'"
- name: Install system dependencies - name: Install system dependencies in container
run: | run: |
PKGS="libpq-dev libssl-dev liblzma-dev pkg-config" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "incus exec system -- bash -c '
MISSING="" PKGS=\"libpq-dev libssl-dev liblzma-dev pkg-config\"
for pkg in $PKGS; do MISSING=\"\"
dpkg -s "$pkg" >/dev/null 2>&1 || MISSING="$MISSING $pkg" for pkg in \$PKGS; do
dpkg -s \"\$pkg\" >/dev/null 2>&1 || MISSING=\"\$MISSING \$pkg\"
done done
if [ -n "$MISSING" ]; then if [ -n \"\$MISSING\" ]; then
sudo apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30 apt-get update -qq -o Acquire::Retries=3 -o Acquire::http::Timeout=30
sudo apt-get install -y --no-install-recommends $MISSING apt-get install -y --no-install-recommends \$MISSING
else else
echo "All system dependencies already installed" echo \"All system dependencies already installed\"
fi fi
'"
- name: Build BotServer - name: Build BotServer inside container
working-directory: /opt/gbo/ci/botserver
run: | run: |
cargo build -p botserver --features chat -j 8 2>&1 | tee /tmp/build.log echo "=== Building BotServer inside container ==="
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=60 system "incus exec system -- bash -c '
cd /opt/gbo/ci/botserver
export CARGO_BUILD_JOBS=4
cargo build -p botserver --features chat 2>&1 | tee /tmp/build.log
ls -lh target/debug/botserver ls -lh target/debug/botserver
'"
- name: Save build log - name: Save build log
if: always()
run: sudo cp /tmp/build.log /tmp/botserver-$(date +%Y%m%d-%H%M%S).log || true
- name: Deploy via ssh tar gzip
run: | run: |
set -e ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "incus exec system -- cat /tmp/build.log > /tmp/botserver-build.log" || true
cat /tmp/botserver-build.log 2>/dev/null | tail -30 || echo "Build log not available"
- name: Deploy BotServer
run: |
echo "=== Deploy started ===" echo "=== Deploy started ==="
echo "Step 1: Checking binary..." ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "incus exec system -- bash -c '
ls -lh /opt/gbo/ci/botserver/target/debug/botserver echo \"Step 1: Killing old botserver...\"
echo "Step 2: Killing old botserver..." pgrep -f botserver && killall botserver 2>/dev/null || echo \"No running botserver\"
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "pgrep -f botserver && killall botserver 2>/dev/null || echo 'No running botserver'" sleep 2
echo "Step 3: Removing old binary..." echo \"Step 2: Removing old binary...\"
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "rm -f /opt/gbo/bin/botserver && echo 'Old binary removed'" rm -f /opt/gbo/bin/botserver
echo "Step 4: Starting tar+gzip transfer..." echo \"Step 3: Copying new binary...\"
tar cf - -C /opt/gbo/ci/botserver/target/debug botserver | gzip -1 | ssh -o StrictHostKeyChecking=no -o ConnectTimeout=60 -o ServerAliveInterval=10 system "gzip -d | tar xf - -C /opt/gbo/bin && echo 'Transfer complete'" cp /opt/gbo/ci/botserver/target/debug/botserver /opt/gbo/bin/botserver
echo "Step 5: Verifying transfer..." chmod +x /opt/gbo/bin/botserver
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "ls -lh /opt/gbo/bin/botserver" echo \"Step 4: Setting permissions...\"
echo "Step 6: Setting permissions..." chown gbuser:gbuser /opt/gbo/bin/botserver
ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "chmod +x /opt/gbo/bin/botserver && chown gbuser:gbuser /opt/gbo/bin/botserver" ls -lh /opt/gbo/bin/botserver
echo "=== Deploy completed ===" echo \"=== Deploy completed ===\"
'"
- name: Verify botserver started - name: Verify botserver started
run: | run: |
sleep 10 sleep 10
ssh -o StrictHostKeyChecking=no system "pgrep -f botserver && echo 'OK: botserver is running' || (echo 'ERROR: botserver not running' && cat /opt/gbo/logs/error.log | tail -20 && exit 1)" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 system "incus exec system -- bash -c '
pgrep -f botserver && echo \"OK: botserver is running\" || (echo \"ERROR: botserver not running\" && cat /opt/gbo/logs/error.log | tail -20 && exit 1)
- name: Save deploy log '"
if: always()
run: sudo cp /tmp/deploy.log /tmp/deploy-$(date +%Y%m%d-%H%M%S).log || true