Something went wrong. Try again.
forked from bgpkit/monocle
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859# syntax=docker/dockerfile:1FROM rust:1-bookworm AS chefWORKDIR /appRUN cargo install cargo-chef --locked
# ------------------------------------------------------------------------------# Planner: extract dependency recipe from Cargo.toml + Cargo.lock + source# structure (crate names, binary/example/example targets). Does NOT compile.# Invalidated on source changes, but runs in seconds.# ------------------------------------------------------------------------------FROM chef AS plannerCOPY . .RUN cargo chef prepare --recipe-path recipe.json
# ------------------------------------------------------------------------------# Builder: compile dependencies from recipe, then the real application source.# The dependency-cook layer is only invalidated when the dependency tree changes# (Cargo.toml/Cargo.lock), NOT on routine source edits.# ------------------------------------------------------------------------------FROM chef AS builderCOPY --from=planner /app/recipe.json recipe.jsonRUN cargo chef cook --release --features cli --bin monocle --recipe-path recipe.jsonCOPY . .RUN cargo build --release --features cli --bin monocle && \ cp /app/target/release/monocle /usr/local/bin/monocle
# ------------------------------------------------------------------------------# Runtime image# ------------------------------------------------------------------------------FROM debian:bookworm-slimRUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl \ && rm -rf /var/lib/apt/lists/*COPY --from=builder /usr/local/bin/monocle /usr/local/bin/monocle
# Run as a non-root user for securityRUN groupadd --system monocle && useradd --system --gid monocle --no-create-home --shell /usr/sbin/nologin monocleRUN mkdir -p /data/monocle /cache/monocle /home/monocle/.config/monocle \ && chown -R monocle:monocle /data/monocle /cache/monocle /home/monocle
USER monocle
# Default config: bind to all interfaces, port 8080ENV MONOCLE_SERVER_ADDRESS=0.0.0.0 \ MONOCLE_SERVER_PORT=8080
# Data and cache directories (mount as volumes for persistence)VOLUME ["/data/monocle", "/cache/monocle"]
ENV MONOCLE_DATA_DIR=/data/monocle \ HOME=/home/monocle
EXPOSE 8080
# `monocle` as the entrypoint with `server` as the default command: a bare# `docker run` still starts the server, while any other subcommand runs with# `docker run IMAGE <command> [...]` (e.g. `docker run IMAGE watch --host rrc00`).ENTRYPOINT ["monocle"]CMD ["server"]