mirror of
https://github.com/tiennm99/docker-images.git
synced 2026-10-13 16:14:50 +00:00
refactor(scribe): normalize ASCII formatting
Remove decorative Unicode banner comments, replace em-dashes with hyphens across Dockerfile, configs, docs, and one Go log string, alphabetize the builder-stage yum package list, and drop the non-standard description/version LABELs from the runtime stage.
This commit is contained in:
1 parent
ff5e5f6a42
commit
afaa631c94
7 files changed
+35
-57
No files matched your search
+13
-35
@@ -1,32 +1,29 @@
|
|||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# Stage 1: builder
|
|
||||||
# CentOS 7 chosen because automake 1.13 predates the 1.14+
|
|
||||||
# "global options already processed" bug, and OpenSSL 1.0.2
|
|
||||||
# has BN_init (required by Thrift 0.9.1).
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
FROM centos:7 AS builder
|
FROM centos:7 AS builder
|
||||||
|
|
||||||
# Versions pinned for reproducibility
|
|
||||||
ENV THRIFT_VERSION=0.9.1
|
ENV THRIFT_VERSION=0.9.1
|
||||||
|
|
||||||
# ── Point yum to vault (CentOS 7 is EOL) ────────────────────
|
# CentOS 7 is EOL, so yum must use the vault repositories.
|
||||||
RUN sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' \
|
RUN sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' \
|
||||||
/etc/yum.repos.d/CentOS-Base.repo
|
/etc/yum.repos.d/CentOS-Base.repo
|
||||||
|
|
||||||
# ── Build-time dependencies ──────────────────────────────────
|
|
||||||
RUN yum install -y \
|
RUN yum install -y \
|
||||||
gcc gcc-c++ make autoconf automake libtool \
|
autoconf \
|
||||||
git wget \
|
automake \
|
||||||
flex bison \
|
bison \
|
||||||
boost-devel \
|
boost-devel \
|
||||||
|
flex \
|
||||||
|
gcc \
|
||||||
|
gcc-c++ \
|
||||||
|
git \
|
||||||
libevent-devel \
|
libevent-devel \
|
||||||
|
libtool \
|
||||||
|
make \
|
||||||
openssl-devel \
|
openssl-devel \
|
||||||
|
wget \
|
||||||
zlib-devel \
|
zlib-devel \
|
||||||
&& yum clean all
|
&& yum clean all
|
||||||
|
|
||||||
# ── Build Apache Thrift ──────────────────────────────────────
|
# Scribe uses Facebook's old Thrift IDL and C++ runtime, which match Apache Thrift 0.9.x.
|
||||||
# Scribe uses the old Facebook Thrift IDL and C++ runtime, which
|
|
||||||
# is API-compatible with Apache Thrift 0.9.x.
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
wget -q "https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz" \
|
wget -q "https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz" \
|
||||||
-O /tmp/thrift.tar.gz; \
|
-O /tmp/thrift.tar.gz; \
|
||||||
@@ -48,8 +45,6 @@ RUN set -eux; \
|
|||||||
make install; \
|
make install; \
|
||||||
ldconfig
|
ldconfig
|
||||||
|
|
||||||
# ── Build fb303 (Scribe dependency) ─────────────────────────
|
|
||||||
# fb303 is Facebook's base service interface, bundled with Thrift.
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
cd /tmp/thrift-${THRIFT_VERSION}/contrib/fb303; \
|
cd /tmp/thrift-${THRIFT_VERSION}/contrib/fb303; \
|
||||||
./bootstrap.sh; \
|
./bootstrap.sh; \
|
||||||
@@ -59,8 +54,6 @@ RUN set -eux; \
|
|||||||
ldconfig; \
|
ldconfig; \
|
||||||
rm -rf /tmp/thrift*
|
rm -rf /tmp/thrift*
|
||||||
|
|
||||||
# ── Build Scribe ─────────────────────────────────────────────
|
|
||||||
# Facebook archived Scribe at https://github.com/facebookarchive/scribe
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
git clone --depth 1 \
|
git clone --depth 1 \
|
||||||
https://github.com/facebookarchive/scribe.git /tmp/scribe; \
|
https://github.com/facebookarchive/scribe.git /tmp/scribe; \
|
||||||
@@ -72,23 +65,14 @@ RUN set -eux; \
|
|||||||
make -C src install; \
|
make -C src install; \
|
||||||
rm -rf /tmp/scribe
|
rm -rf /tmp/scribe
|
||||||
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# Stage 2: runtime
|
|
||||||
# Minimal image containing only the runtime libraries and the
|
|
||||||
# compiled scribed binary.
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
FROM centos:7
|
FROM centos:7
|
||||||
|
|
||||||
LABEL maintainer="Tien Nguyen Minh <tiennm99@outlook.com>"
|
LABEL maintainer="Tien Nguyen Minh <tiennm99@outlook.com>"
|
||||||
LABEL description="Facebook Legacy Scribe – real-time log aggregation daemon"
|
|
||||||
LABEL version="2.2"
|
|
||||||
|
|
||||||
# ── Point yum to vault (CentOS 7 is EOL) ────────────────────
|
# CentOS 7 is EOL, so yum must use the vault repositories.
|
||||||
RUN sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' \
|
RUN sed -i 's|^mirrorlist=|#mirrorlist=|g; s|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' \
|
||||||
/etc/yum.repos.d/CentOS-Base.repo
|
/etc/yum.repos.d/CentOS-Base.repo
|
||||||
|
|
||||||
# ── Runtime-only shared libraries ────────────────────────────
|
|
||||||
RUN yum install -y \
|
RUN yum install -y \
|
||||||
boost-filesystem \
|
boost-filesystem \
|
||||||
boost-system \
|
boost-system \
|
||||||
@@ -97,28 +81,22 @@ RUN yum install -y \
|
|||||||
openssl \
|
openssl \
|
||||||
&& yum clean all
|
&& yum clean all
|
||||||
|
|
||||||
# Copy only what is needed from the builder stage
|
|
||||||
COPY --from=builder /usr/local/bin/scribed /usr/local/bin/scribed
|
COPY --from=builder /usr/local/bin/scribed /usr/local/bin/scribed
|
||||||
COPY --from=builder /usr/local/lib/libthrift*.so* /usr/local/lib/
|
COPY --from=builder /usr/local/lib/libthrift*.so* /usr/local/lib/
|
||||||
COPY --from=builder /usr/local/lib/libfb303*.so* /usr/local/lib/
|
COPY --from=builder /usr/local/lib/libfb303*.so* /usr/local/lib/
|
||||||
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/scribe.conf && ldconfig
|
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/scribe.conf && ldconfig
|
||||||
|
|
||||||
# ── Least-privilege user ─────────────────────────────────────
|
|
||||||
RUN groupadd -r scribe \
|
RUN groupadd -r scribe \
|
||||||
&& useradd -r -g scribe -s /sbin/nologin scribe \
|
&& useradd -r -g scribe -s /sbin/nologin scribe \
|
||||||
&& mkdir -p /var/log/scribe /etc/scribe \
|
&& mkdir -p /var/log/scribe /etc/scribe \
|
||||||
&& chown -R scribe:scribe /var/log/scribe /etc/scribe
|
&& chown -R scribe:scribe /var/log/scribe /etc/scribe
|
||||||
|
|
||||||
# ── Default configuration and entrypoint ─────────────────────
|
|
||||||
COPY config/scribe.conf /etc/scribe/scribe.conf
|
COPY config/scribe.conf /etc/scribe/scribe.conf
|
||||||
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
# /var/log/scribe – persistent log output (mount a volume here)
|
|
||||||
# /etc/scribe – configuration (mount a custom scribe.conf here)
|
|
||||||
VOLUME ["/var/log/scribe", "/etc/scribe"]
|
VOLUME ["/var/log/scribe", "/etc/scribe"]
|
||||||
|
|
||||||
# Scribe listens on this TCP port by default
|
|
||||||
EXPOSE 1463
|
EXPOSE 1463
|
||||||
|
|
||||||
USER scribe
|
USER scribe
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ docker build -t scribe:2.2 .
|
|||||||
```
|
```
|
||||||
|
|
||||||
The Dockerfile uses a two-stage build:
|
The Dockerfile uses a two-stage build:
|
||||||
1. **builder** – compiles Apache Thrift 0.9.1 and Scribe from source on CentOS 7
|
1. **builder** - compiles Apache Thrift 0.9.1 and Scribe from source on CentOS 7
|
||||||
2. **runtime** – copies only the compiled binary and required shared libraries
|
2. **runtime** - copies only the compiled binary and required shared libraries
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# scribe.conf – default Scribe server configuration
|
# scribe.conf - default Scribe server configuration
|
||||||
#
|
#
|
||||||
# Scribe uses a simple key=value / <store> block format.
|
# Scribe uses a simple key=value / <store> block format.
|
||||||
# Full reference: https://github.com/facebookarchive/scribe/wiki/Scribe-Configuration
|
# Full reference: https://github.com/facebookarchive/scribe/wiki/Scribe-Configuration
|
||||||
|
|
||||||
# ── Network ──────────────────────────────────────────────────
|
# Network
|
||||||
# TCP port scribed listens on (Thrift binary protocol)
|
# TCP port scribed listens on (Thrift binary protocol)
|
||||||
port=1463
|
port=1463
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ max_msg_per_second=100000
|
|||||||
# Maximum message size in bytes (default 16 MB)
|
# Maximum message size in bytes (default 16 MB)
|
||||||
max_msg_size=16777216
|
max_msg_size=16777216
|
||||||
|
|
||||||
# ── Health check interval ────────────────────────────────────
|
# Health check interval
|
||||||
# How often (seconds) scribed checks whether stores are active
|
# How often (seconds) scribed checks whether stores are active
|
||||||
check_interval=3
|
check_interval=3
|
||||||
|
|
||||||
# ── Default catch-all store ──────────────────────────────────
|
# Default catch-all store
|
||||||
# Any category not matched by a specific <store> block falls here.
|
# Any category not matched by a specific <store> block falls here.
|
||||||
# Messages are written to rotating hourly files under /var/log/scribe/<category>/.
|
# Messages are written to rotating hourly files under /var/log/scribe/<category>/.
|
||||||
<store>
|
<store>
|
||||||
@@ -30,7 +30,7 @@ rotate_period=hourly
|
|||||||
write_meta=true
|
write_meta=true
|
||||||
</store>
|
</store>
|
||||||
|
|
||||||
# ── Example: category-specific store ─────────────────────────
|
# Example: category-specific store
|
||||||
# Uncomment and adapt to route a named category to its own directory.
|
# Uncomment and adapt to route a named category to its own directory.
|
||||||
#
|
#
|
||||||
# <store>
|
# <store>
|
||||||
@@ -42,7 +42,7 @@ write_meta=true
|
|||||||
# rotate_period=daily
|
# rotate_period=daily
|
||||||
# </store>
|
# </store>
|
||||||
|
|
||||||
# ── Example: network store (relay to upstream Scribe) ─────────
|
# Example: network store (relay to upstream Scribe)
|
||||||
# Forward all messages to an upstream Scribe instance.
|
# Forward all messages to an upstream Scribe instance.
|
||||||
#
|
#
|
||||||
# <store>
|
# <store>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ A one-command demo that proves the Scribe config actually writes logs.
|
|||||||
Thrift, pushes a few messages, and exits. The resulting log files appear on your host under
|
Thrift, pushes a few messages, and exits. The resulting log files appear on your host under
|
||||||
[`./logs`](./logs).
|
[`./logs`](./logs).
|
||||||
|
|
||||||
> Scribe is receive-only — it writes **nothing** until a client sends it messages. The Go
|
> Scribe is receive-only - it writes **nothing** until a client sends it messages. The Go
|
||||||
> sender is what makes this example produce log files.
|
> sender is what makes this example produce log files.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -38,7 +38,7 @@ ls logs/example/
|
|||||||
cat logs/example/example-*_00000
|
cat logs/example/example-*_00000
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see the five `Hello from Go sender — message N/5` lines.
|
You should see the five `Hello from Go sender - message N/5` lines.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -48,17 +48,17 @@ Adjust the sender via environment variables in [`docker-compose.yml`](./docker-c
|
|||||||
|
|
||||||
| Env | Default | Purpose |
|
| Env | Default | Purpose |
|
||||||
|-----|---------|---------|
|
|-----|---------|---------|
|
||||||
| `SCRIBE_CATEGORY` | `example` | Message category → log subdirectory name |
|
| `SCRIBE_CATEGORY` | `example` | Message category to log subdirectory name |
|
||||||
| `SCRIBE_COUNT` | `5` | Number of messages to send |
|
| `SCRIBE_COUNT` | `5` | Number of messages to send |
|
||||||
| `SCRIBE_HOST` | `scribe` | Daemon hostname (compose service name) |
|
| `SCRIBE_HOST` | `scribe` | Daemon hostname (compose service name) |
|
||||||
| `SCRIBE_PORT` | `1463` | Thrift port |
|
| `SCRIBE_PORT` | `1463` | Thrift port |
|
||||||
|
|
||||||
To change *where/how* Scribe stores logs (rotation, store type, per-category routing), edit
|
To change *where/how* Scribe stores logs (rotation, store type, per-category routing), edit
|
||||||
[`config/scribe.conf`](../config/scribe.conf) — see the
|
[`config/scribe.conf`](../config/scribe.conf) - see the
|
||||||
[Configuration Reference](../README.md#configuration-reference).
|
[Configuration Reference](../README.md#configuration-reference).
|
||||||
|
|
||||||
The sender ([`sender/main.go`](./sender/main.go)) hand-encodes the Thrift framed binary
|
The sender ([`sender/main.go`](./sender/main.go)) hand-encodes the Thrift framed binary
|
||||||
`Log()` call using only the Go standard library — no Apache Thrift dependency, no generated
|
`Log()` call using only the Go standard library - no Apache Thrift dependency, no generated
|
||||||
bindings. For the higher-level client API, see the Python snippet in the
|
bindings. For the higher-level client API, see the Python snippet in the
|
||||||
[main README](../README.md#sending-log-messages).
|
[main README](../README.md#sending-log-messages).
|
||||||
|
|
||||||
@@ -66,9 +66,9 @@ bindings. For the higher-level client API, see the Python snippet in the
|
|||||||
|
|
||||||
## Troubleshoot
|
## Troubleshoot
|
||||||
|
|
||||||
- **`logs/` stays empty** — no messages were written yet. Check the `sender` output in the
|
- **`logs/` stays empty** - no messages were written yet. Check the `sender` output in the
|
||||||
compose logs; it exits non-zero and logs the cause if the send failed.
|
compose logs; it exits non-zero and logs the cause if the send failed.
|
||||||
- **Permission denied writing logs (native Linux hosts)** — Scribe runs as a non-root user
|
- **Permission denied writing logs (native Linux hosts)** - Scribe runs as a non-root user
|
||||||
inside the container, which may not be able to write to the bind-mounted host directory.
|
inside the container, which may not be able to write to the bind-mounted host directory.
|
||||||
Fix by loosening the local dir before running:
|
Fix by loosening the local dir before running:
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ bindings. For the higher-level client API, see the Python snippet in the
|
|||||||
```
|
```
|
||||||
|
|
||||||
On Docker Desktop (Windows/macOS) this is normally not needed.
|
On Docker Desktop (Windows/macOS) this is normally not needed.
|
||||||
- **Sender can't connect** — it retries for ~10s on startup. If Scribe takes longer to boot,
|
- **Sender can't connect** - it retries for ~10s on startup. If Scribe takes longer to boot,
|
||||||
re-run `docker compose up` or increase the retry window in `sender/main.go`.
|
re-run `docker compose up` or increase the retry window in `sender/main.go`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
# Reuse the repo's default config (read-only).
|
# Reuse the repo's default config (read-only).
|
||||||
- ../config/scribe.conf:/etc/scribe/scribe.conf:ro
|
- ../config/scribe.conf:/etc/scribe/scribe.conf:ro
|
||||||
# Host-visible log output — files land here after the sender runs.
|
# Host-visible log output: files land here after the sender runs.
|
||||||
- ./logs:/var/log/scribe
|
- ./logs:/var/log/scribe
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// daemon to demonstrate that the example writes real log files.
|
// daemon to demonstrate that the example writes real log files.
|
||||||
//
|
//
|
||||||
// It speaks Scribe's Thrift RPC by hand-encoding the framed binary `Log()` call
|
// It speaks Scribe's Thrift RPC by hand-encoding the framed binary `Log()` call
|
||||||
// using only the Go standard library — no Apache Thrift dependency and no
|
// using only the Go standard library - no Apache Thrift dependency and no
|
||||||
// generated bindings. The Scribe Thrift contract:
|
// generated bindings. The Scribe Thrift contract:
|
||||||
//
|
//
|
||||||
// enum ResultCode { OK = 0, TRY_LATER = 1 }
|
// enum ResultCode { OK = 0, TRY_LATER = 1 }
|
||||||
@@ -122,7 +122,7 @@ func readResultCode(r io.Reader) (int32, error) {
|
|||||||
}
|
}
|
||||||
br := bytes.NewReader(frame)
|
br := bytes.NewReader(frame)
|
||||||
|
|
||||||
// messageBegin — detect strict vs non-strict from the first i32.
|
// messageBegin: detect strict vs non-strict from the first i32.
|
||||||
var i32buf [4]byte
|
var i32buf [4]byte
|
||||||
if _, err := io.ReadFull(br, i32buf[:]); err != nil {
|
if _, err := io.ReadFull(br, i32buf[:]); err != nil {
|
||||||
return -1, fmt.Errorf("read message header: %w", err)
|
return -1, fmt.Errorf("read message header: %w", err)
|
||||||
@@ -158,7 +158,7 @@ func readResultCode(r io.Reader) (int32, error) {
|
|||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
if typeID == tSTOP {
|
if typeID == tSTOP {
|
||||||
return 0, nil // no return field present → treat as OK
|
return 0, nil // no return field present; treat as OK
|
||||||
}
|
}
|
||||||
var idBuf [2]byte
|
var idBuf [2]byte
|
||||||
if _, err := io.ReadFull(br, idBuf[:]); err != nil {
|
if _, err := io.ReadFull(br, idBuf[:]); err != nil {
|
||||||
@@ -208,7 +208,7 @@ func main() {
|
|||||||
|
|
||||||
messages := make([]string, 0, count)
|
messages := make([]string, 0, count)
|
||||||
for i := 1; i <= count; i++ {
|
for i := 1; i <= count; i++ {
|
||||||
messages = append(messages, fmt.Sprintf("Hello from Go sender — message %d/%d", i, count))
|
messages = append(messages, fmt.Sprintf("Hello from Go sender - message %d/%d", i, count))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := conn.Write(buildLogFrame(category, messages)); err != nil {
|
if _, err := conn.Write(buildLogFrame(category, messages)); err != nil {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# docker-entrypoint.sh – Scribe daemon startup script
|
# docker-entrypoint.sh - Scribe daemon startup script
|
||||||
#
|
#
|
||||||
# Reads SCRIBE_CONFIG env var (default: /etc/scribe/scribe.conf)
|
# Reads SCRIBE_CONFIG env var (default: /etc/scribe/scribe.conf)
|
||||||
# and launches scribed with that configuration file.
|
# and launches scribed with that configuration file.
|
||||||
|
|||||||
Reference in new issue
Block a user