Research-Stack/4-Infrastructure/infra/embedded_surface/Dockerfile
Brandon Schneider a9f3d3d487 ene-session-sync: add meta_autotype.rs; embedded_surface: Rust rs-surface daemon
- src/meta_autotype.rs (396L): port ene_meta_autotype.py — deterministic
  ContingentField classifier with scalar_type, bind_class, surface_hint,
  autotype_payload, handle_request, and 3 unit tests (all green).
- Cargo.toml: wire meta_autotype mod, add tempfile dev-dep for existing tests.
- embedded_surface/rs-surface/ (1025L): full Rust port of server.py.
  - axum 0.7 HTTP server + WebSocket binary surface-frame protocol.
  - All 16 op-codes: HEALTH, STATUS, METRICS, ATTEST, COMPRESS, RGFLOW,
    ROUTE, MOUNT_STATUS, SNAPSHOT, ENTER_RECOVERY, PRIMITIVES, PLAN_ROUTE,
    WIKI, FRACTAL_FOLD, META_AUTOTYPE, CREDENTIALS.
  - Inline omni_lut choose_route (choose_route fn, shannon_entropy,
    detect_sequence_surface, s3c_shear) — no Python deps.
  - Inline meta_autotype_payload — mirrors handle_request from ene_meta_autotype.py.
  - Same wire framing: [v][flags][codec][op][req_id][len][crc32][payload].
- Dockerfile: multi-stage Rust builder (alpine) + minimal runtime image;
  Python server.py kept as fallback alongside binary.
- cargo build: 0 errors on both crates; meta_autotype tests: 3/3 pass.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-05-19 14:11:47 +00:00

39 lines
1.6 KiB
Docker

# ── Stage 1: build the Rust surface binary ─────────────────────────────────
FROM rust:1.82-alpine AS builder
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static pkgconfig
WORKDIR /build
COPY rs-surface/Cargo.toml rs-surface/Cargo.lock ./
# Pre-fetch deps (layer cache)
RUN mkdir src && echo 'fn main(){}' > src/main.rs && cargo build --release 2>/dev/null || true
COPY rs-surface/src ./src
RUN touch src/main.rs && cargo build --release
# ── Stage 2: minimal runtime image ─────────────────────────────────────────
FROM alpine:3.20
ENV RS_SURFACE_PROFILE=/etc/rs-surface/node.json
ENV RS_SURFACE_STATE=/var/lib/rs-surface
ENV RS_SURFACE_MOUNT=/mnt/topological-storage
ENV RS_SURFACE_HOST=0.0.0.0
ENV RS_SURFACE_PORT=8080
RUN adduser -D -H -u 988 surface \
&& mkdir -p /opt/rs-surface /etc/rs-surface /var/lib/rs-surface /var/log/rs-surface /run/rs-surface /mnt/topological-storage \
&& chown -R surface:surface /var/lib/rs-surface /var/log/rs-surface /run/rs-surface /mnt/topological-storage
COPY --from=builder /build/target/release/rs-surface /opt/rs-surface/rs-surface
COPY profiles/racknerd-surface.json /etc/rs-surface/node.json
# Keep the Python server alongside for fallback / debugging
COPY server.py /opt/rs-surface/server.py
USER surface
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=3s --retries=3 \
CMD wget -qO- http://127.0.0.1:${RS_SURFACE_PORT}/health || exit 1
CMD ["/opt/rs-surface/rs-surface"]