-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (54 loc) · 2.17 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (54 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# syntax=docker/dockerfile:1
# nir-rs — published image for GHCR + Docker Hub.
#
# Builder: cargo test --all-features + release example with system libhdf5.
# Runtime: Rust pin + libhdf5 + source (no target/) + example binary.
# WORKDIR stays /src so env!(CARGO_MANIFEST_DIR) from the builder still finds
# tests/fixtures. Non-root user owns /src so cargo can recreate target/.
# No Python (AGENTS.md).
ARG RUST_IMAGE=rust:1.98.1-bookworm
FROM ${RUST_IMAGE} AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
pkg-config \
libhdf5-dev \
build-essential \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
RUN rustup component add clippy rustfmt \
&& cargo test --all-features \
&& cargo build --release --example load_inspect_lif --features hdf5 \
&& cp target/release/examples/load_inspect_lif /tmp/load_inspect_lif \
&& rm -rf target
FROM ${RUST_IMAGE}
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
pkg-config \
libhdf5-dev \
build-essential \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& rustup component add clippy rustfmt \
&& useradd --create-home --uid 10001 --shell /bin/bash nir
# Match builder path for CARGO_MANIFEST_DIR baked into the example binary.
# Own /src itself so the runtime user can recreate target/ for cargo build/test.
RUN mkdir -p /src && chown nir:nir /src
WORKDIR /src
COPY --from=builder --chown=nir:nir /src /src
COPY --from=builder /tmp/load_inspect_lif /usr/local/bin/load_inspect_lif
RUN chmod 755 /usr/local/bin/load_inspect_lif
USER nir
ENV CARGO_HOME=/home/nir/.cargo \
CARGO_TERM_COLOR=always \
PATH=/home/nir/.cargo/bin:/usr/local/cargo/bin:$PATH
# Pre-warm crate index for agent use; tolerate offline builders.
RUN cargo fetch || true
LABEL org.opencontainers.image.title="nir-rs" \
org.opencontainers.image.description="Pure-Rust NIR graph + HDF5 I/O toolchain image" \
org.opencontainers.image.source="https://github.com/Limen-Neural/nir-rs" \
org.opencontainers.image.licenses="MIT OR Apache-2.0"
CMD ["rustc", "--version"]