NTP-Timeturner/Dockerfile
Chaos Rogers 90cc95be21 refactor: switch PTP daemon to linuxptp/ptp4l; remove statime
Co-authored-by: aider (openai/gpt-5) <aider@aider.chat>
2025-10-22 13:24:05 +01:00

51 lines
1.3 KiB
Docker

# Multi-stage build for Rust Linux container
FROM rust:1.82-bookworm AS builder
# Build dependencies (libudev for serialport on Linux)
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libudev-dev \
build-essential \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Leverage docker layer caching for dependencies
COPY Cargo.toml ./
RUN mkdir -p src && echo 'fn main() { println!("cargo:rerun-if-changed=build.rs"); }' > src/main.rs
RUN cargo build --release || true
RUN rm -rf src
# Copy full source and build project
COPY . .
RUN cargo build --release
# (Statime installation removed; container runs only haci)
# Runtime image
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libudev1 \
ca-certificates \
tzdata \
socat \
linuxptp \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/get-haci /usr/local/bin/get-haci
# Using linuxptp (ptp4l) provided by apt; no statime binary copied
COPY static ./static
COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY scripts/ltc_gen.sh /usr/local/bin/ltc-gen.sh
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/ltc-gen.sh
ENV RUST_LOG=info
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["get-haci"]