mirror of
https://github.com/tiennm99/docker-images.git
synced 2026-10-12 16:15:17 +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
|
||||
|
||||
# Versions pinned for reproducibility
|
||||
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' \
|
||||
/etc/yum.repos.d/CentOS-Base.repo
|
||||
|
||||
# ── Build-time dependencies ──────────────────────────────────
|
||||
RUN yum install -y \
|
||||
gcc gcc-c++ make autoconf automake libtool \
|
||||
git wget \
|
||||
flex bison \
|
||||
autoconf \
|
||||
automake \
|
||||
bison \
|
||||
boost-devel \
|
||||
flex \
|
||||
gcc \
|
||||
gcc-c++ \
|
||||
git \
|
||||
libevent-devel \
|
||||
libtool \
|
||||
make \
|
||||
openssl-devel \
|
||||
wget \
|
||||
zlib-devel \
|
||||
&& yum clean all
|
||||
|
||||
# ── Build Apache Thrift ──────────────────────────────────────
|
||||
# Scribe uses the old Facebook Thrift IDL and C++ runtime, which
|
||||
# is API-compatible with Apache Thrift 0.9.x.
|
||||
# Scribe uses Facebook's old Thrift IDL and C++ runtime, which match Apache Thrift 0.9.x.
|
||||
RUN set -eux; \
|
||||
wget -q "https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz" \
|
||||
-O /tmp/thrift.tar.gz; \
|
||||
@@ -48,8 +45,6 @@ RUN set -eux; \
|
||||
make install; \
|
||||
ldconfig
|
||||
|
||||
# ── Build fb303 (Scribe dependency) ─────────────────────────
|
||||
# fb303 is Facebook's base service interface, bundled with Thrift.
|
||||
RUN set -eux; \
|
||||
cd /tmp/thrift-${THRIFT_VERSION}/contrib/fb303; \
|
||||
./bootstrap.sh; \
|
||||
@@ -59,8 +54,6 @@ RUN set -eux; \
|
||||
ldconfig; \
|
||||
rm -rf /tmp/thrift*
|
||||
|
||||
# ── Build Scribe ─────────────────────────────────────────────
|
||||
# Facebook archived Scribe at https://github.com/facebookarchive/scribe
|
||||
RUN set -eux; \
|
||||
git clone --depth 1 \
|
||||
https://github.com/facebookarchive/scribe.git /tmp/scribe; \
|
||||
@@ -72,23 +65,14 @@ RUN set -eux; \
|
||||
make -C src install; \
|
||||
rm -rf /tmp/scribe
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
# Stage 2: runtime
|
||||
# Minimal image containing only the runtime libraries and the
|
||||
# compiled scribed binary.
|
||||
# ─────────────────────────────────────────────────────────────
|
||||
FROM centos:7
|
||||
|
||||
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' \
|
||||
/etc/yum.repos.d/CentOS-Base.repo
|
||||
|
||||
# ── Runtime-only shared libraries ────────────────────────────
|
||||
RUN yum install -y \
|
||||
boost-filesystem \
|
||||
boost-system \
|
||||
@@ -97,28 +81,22 @@ RUN yum install -y \
|
||||
openssl \
|
||||
&& 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/lib/libthrift*.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
|
||||
|
||||
# ── Least-privilege user ─────────────────────────────────────
|
||||
RUN groupadd -r scribe \
|
||||
&& useradd -r -g scribe -s /sbin/nologin scribe \
|
||||
&& mkdir -p /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 scripts/docker-entrypoint.sh /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"]
|
||||
|
||||
# Scribe listens on this TCP port by default
|
||||
EXPOSE 1463
|
||||
|
||||
USER scribe
|
||||
|
||||
@@ -154,8 +154,8 @@ docker build -t scribe:2.2 .
|
||||
```
|
||||
|
||||
The Dockerfile uses a two-stage build:
|
||||
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
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -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.
|
||||
# Full reference: https://github.com/facebookarchive/scribe/wiki/Scribe-Configuration
|
||||
|
||||
# ── Network ──────────────────────────────────────────────────
|
||||
# Network
|
||||
# TCP port scribed listens on (Thrift binary protocol)
|
||||
port=1463
|
||||
|
||||
@@ -13,11 +13,11 @@ max_msg_per_second=100000
|
||||
# Maximum message size in bytes (default 16 MB)
|
||||
max_msg_size=16777216
|
||||
|
||||
# ── Health check interval ────────────────────────────────────
|
||||
# Health check interval
|
||||
# How often (seconds) scribed checks whether stores are active
|
||||
check_interval=3
|
||||
|
||||
# ── Default catch-all store ──────────────────────────────────
|
||||
# Default catch-all store
|
||||
# Any category not matched by a specific <store> block falls here.
|
||||
# Messages are written to rotating hourly files under /var/log/scribe/<category>/.
|
||||
<store>
|
||||
@@ -30,7 +30,7 @@ rotate_period=hourly
|
||||
write_meta=true
|
||||
</store>
|
||||
|
||||
# ── Example: category-specific store ─────────────────────────
|
||||
# Example: category-specific store
|
||||
# Uncomment and adapt to route a named category to its own directory.
|
||||
#
|
||||
# <store>
|
||||
@@ -42,7 +42,7 @@ write_meta=true
|
||||
# rotate_period=daily
|
||||
# </store>
|
||||
|
||||
# ── Example: network store (relay to upstream Scribe) ─────────
|
||||
# Example: network store (relay to upstream Scribe)
|
||||
# Forward all messages to an upstream Scribe instance.
|
||||
#
|
||||
# <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
|
||||
[`./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.
|
||||
|
||||
---
|
||||
@@ -38,7 +38,7 @@ ls logs/example/
|
||||
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 |
|
||||
|-----|---------|---------|
|
||||
| `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_HOST` | `scribe` | Daemon hostname (compose service name) |
|
||||
| `SCRIBE_PORT` | `1463` | Thrift port |
|
||||
|
||||
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).
|
||||
|
||||
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
|
||||
[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
|
||||
|
||||
- **`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.
|
||||
- **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.
|
||||
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.
|
||||
- **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`.
|
||||
|
||||
---
|
||||
|
||||
@@ -9,7 +9,7 @@ services:
|
||||
volumes:
|
||||
# Reuse the repo's default config (read-only).
|
||||
- ../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
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// daemon to demonstrate that the example writes real log files.
|
||||
//
|
||||
// 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:
|
||||
//
|
||||
// enum ResultCode { OK = 0, TRY_LATER = 1 }
|
||||
@@ -122,7 +122,7 @@ func readResultCode(r io.Reader) (int32, error) {
|
||||
}
|
||||
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
|
||||
if _, err := io.ReadFull(br, i32buf[:]); err != nil {
|
||||
return -1, fmt.Errorf("read message header: %w", err)
|
||||
@@ -158,7 +158,7 @@ func readResultCode(r io.Reader) (int32, error) {
|
||||
return -1, err
|
||||
}
|
||||
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
|
||||
if _, err := io.ReadFull(br, idBuf[:]); err != nil {
|
||||
@@ -208,7 +208,7 @@ func main() {
|
||||
|
||||
messages := make([]string, 0, count)
|
||||
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 {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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)
|
||||
# and launches scribed with that configuration file.
|
||||
|
||||
Reference in new issue
Block a user