Adds a multi-stage Dockerfile (rust:1-slim-bookworm builder → distroless/cc runtime) plus a --host flag for obscura serve that defaults to 127.0.0.1 for safety but can be set to 0.0.0.0 so the container's port is reachable via docker run -p mapping. Dockerfile cherry-picked from #84. The SPA chunk loading commit from that PR was left out — verified it didn't actually fix the Next.js webpack errors on kiwi.com (#86).
51 lines
1.9 KiB
Docker
51 lines
1.9 KiB
Docker
FROM rust:1-slim-bookworm AS builder
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
ca-certificates \
|
|
perl \
|
|
make \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
|
|
# Cache dependency compilation by copying manifests first
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates/obscura-dom/Cargo.toml crates/obscura-dom/Cargo.toml
|
|
COPY crates/obscura-net/Cargo.toml crates/obscura-net/Cargo.toml
|
|
COPY crates/obscura-browser/Cargo.toml crates/obscura-browser/Cargo.toml
|
|
COPY crates/obscura-cdp/Cargo.toml crates/obscura-cdp/Cargo.toml
|
|
COPY crates/obscura-js/Cargo.toml crates/obscura-js/Cargo.toml
|
|
COPY crates/obscura-mcp/Cargo.toml crates/obscura-mcp/Cargo.toml
|
|
COPY crates/obscura-cli/Cargo.toml crates/obscura-cli/Cargo.toml
|
|
|
|
# Create stub src files so cargo can resolve the dependency graph
|
|
RUN for crate in obscura-dom obscura-net obscura-browser obscura-cdp obscura-js obscura-mcp; do \
|
|
mkdir -p crates/$crate/src && echo "// stub" > crates/$crate/src/lib.rs; \
|
|
done && \
|
|
mkdir -p crates/obscura-cli/src && \
|
|
echo "fn main() {}" > crates/obscura-cli/src/main.rs && \
|
|
echo "fn main() {}" > crates/obscura-cli/src/worker.rs
|
|
|
|
RUN cargo build --release --bin obscura --bin obscura-worker 2>/dev/null || true
|
|
|
|
# Copy real sources and build
|
|
COPY crates/ crates/
|
|
RUN touch crates/*/src/*.rs && cargo build --release --bin obscura --bin obscura-worker
|
|
|
|
# ---
|
|
|
|
# distroless/cc: glibc + libgcc + CA certs only — no shell, no package manager
|
|
FROM gcr.io/distroless/cc-debian12
|
|
|
|
COPY --from=builder /build/target/release/obscura /obscura
|
|
COPY --from=builder /build/target/release/obscura-worker /obscura-worker
|
|
|
|
EXPOSE 9222
|
|
|
|
# Bind to 0.0.0.0 so the port is reachable via `docker run -p 9222:9222`.
|
|
# Native binary still defaults to 127.0.0.1 (loopback only) — this override
|
|
# is just for the container.
|
|
ENTRYPOINT ["/obscura"]
|
|
CMD ["serve", "--port", "9222", "--host", "0.0.0.0"]
|