Skip to content

Commit 5a270f1

Browse files
author
Developer
committed
fix: locate mariadb-binlog dynamically in agent image
apk add succeeded on Alpine 3.20 + mariadb 10.11.18 but /usr/bin/mariadb-binlog wasn't at that exact path, breaking the hardcoded `test -x`. Use `command -v` with a `/usr` find fallback so the symlink target resolves at build time regardless of where the package lays the binary down, and verify with `mysqlbinlog --version`.
1 parent cc42578 commit 5a270f1

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ RUN npm run build
4343
# =============================================================================
4444
FROM alpine:3.20 AS agent
4545

46-
# mariadb-client provides mysqlbinlog (symlinked for name compatibility),
47-
# which the agent uses to parse local binlog files.
48-
RUN apk add --no-cache ca-certificates tzdata mariadb-client mariadb-server-utils && \
49-
ln -sf /usr/bin/mariadb-binlog /usr/bin/mysqlbinlog && \
50-
test -x /usr/bin/mysqlbinlog
46+
# mariadb-client provides mariadb-binlog, which the agent uses to parse local
47+
# binlog files. We locate the binary dynamically (path varies across Alpine /
48+
# MariaDB versions) and expose it as mysqlbinlog for the agent's PATH lookup.
49+
RUN set -e && \
50+
apk add --no-cache ca-certificates tzdata mariadb-client mariadb-server-utils && \
51+
BINLOG="$(command -v mariadb-binlog || true)" && \
52+
if [ -z "$BINLOG" ]; then \
53+
BINLOG="$(find /usr -type f -name 'mariadb-binlog' 2>/dev/null | head -n1)"; \
54+
fi && \
55+
if [ -z "$BINLOG" ]; then \
56+
echo "ERROR: mariadb-binlog not found after apk add" >&2; exit 1; \
57+
fi && \
58+
ln -sf "$BINLOG" /usr/bin/mysqlbinlog && \
59+
/usr/bin/mysqlbinlog --version >/dev/null && \
60+
echo "linked mysqlbinlog -> $BINLOG"
5161

5262
COPY --from=builder /build/mysql-pitr-agent /usr/local/bin/mysql-pitr-agent
5363

0 commit comments

Comments
 (0)