From e54f6518b85309203ca066446e6629dd22e16a76 Mon Sep 17 00:00:00 2001 From: Bailey Townsend Date: Mon, 15 Jun 2026 16:45:49 -0500 Subject: [PATCH] Slingshot docker files (still need testing) --- .gitignore | 1 + docker-compose.yml | 26 ++++++++++++++++++++++++ slingshot/Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 slingshot/Dockerfile diff --git a/.gitignore b/.gitignore index eae1adb..2a4cd66 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ local/ rocks.test constellation-data +slingshot-data diff --git a/docker-compose.yml b/docker-compose.yml index f603613..f5b6b01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,5 +26,31 @@ services: - "0.0.0.0:8765" restart: unless-stopped + slingshot: + build: + context: . + dockerfile: ./slingshot/Dockerfile + container_name: slingshot + environment: + - RUST_LOG=info + ports: + - "8080:8080" # HTTP / XRPC API + - "8766:8765" # prometheus metrics (host 8766 to avoid clashing with constellation's 8765) + # Saves caches directly to a folder on disk + volumes: + - ./slingshot-data:/data + command: + - "--jetstream" + - "us-east-1" + - "--cache-dir" + - "/data" + - "--bind" + - "0.0.0.0:8080" + - "--collect-metrics" + - "--bind-metrics" + - "0.0.0.0:8765" + restart: unless-stopped + volumes: constellation-data: + slingshot-data: diff --git a/slingshot/Dockerfile b/slingshot/Dockerfile new file mode 100644 index 0000000..d551120 --- /dev/null +++ b/slingshot/Dockerfile @@ -0,0 +1,47 @@ +# Multi-stage build for slingshot. +# +# The build context must be the workspace ROOT (microcosm-rs/) +FROM rust:1.96-bookworm AS builder + +# aws-lc-sys (pulled in via rustls' default aws-lc-rs provider) builds a C +# library with cmake and runs bindgen (needs libclang); reqwest's default-tls +# and jetstream's tungstenite native-tls need OpenSSL headers. +RUN apt-get update && apt-get install -y --no-install-recommends \ + clang \ + libclang-dev \ + build-essential \ + cmake \ + libssl-dev \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY . . + +# Cache the cargo registry and target dir across builds. Because the target dir +# lives in a cache mount (not the layer), copy the finished binary out in the +# same RUN so it survives into the image. +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/app/target \ + cargo build --release -p slingshot \ + && cp target/release/slingshot /usr/local/bin/slingshot + +FROM debian:12.14-slim AS runtime + +# ca-certificates for TLS to jetstream/plc; libssl3 for native-tls at runtime. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + libssl3 \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/local/bin/slingshot /usr/local/bin/slingshot + +# slingshot serves ./static/index.html relative to its working directory. +WORKDIR /app +COPY --from=builder /app/slingshot/static ./static + +RUN mkdir -p /data +VOLUME ["/data"] + +ENTRYPOINT ["slingshot"] +CMD ["--help"] -- 2.51.2