diff --git a/Dockerfile b/Dockerfile index 70abacd..1624a40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,10 @@ RUN rm -rf src COPY . . RUN cargo build --release --bin ntp_timeturner --bin ptp_probe +# Build and install the Statime PTP daemon (from crates.io) +# This installs the 'statime' binary into /usr/local/cargo/bin/statime in the builder image. +RUN cargo install --locked statime-linux --version 0.4.0 + # Runtime image FROM debian:bookworm-slim AS runtime @@ -35,6 +39,7 @@ WORKDIR /app COPY --from=builder /app/target/release/ntp_timeturner /usr/local/bin/ntp_timeturner COPY --from=builder /app/target/release/ptp_probe /usr/local/bin/ptp_probe +COPY --from=builder /usr/local/cargo/bin/statime /usr/local/bin/statime COPY static ./static ENV RUST_LOG=info diff --git a/docker-compose.yml b/docker-compose.yml index 5df7f91..45d54d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,3 +26,23 @@ services: devices: - "/dev/ptp0:/dev/ptp0" restart: "no" + + # PTP daemon using Statime (software PTP inside the container) + # Note: On macOS with Docker Desktop, low-level PTP networking features are limited. + # This service is most effective on a Linux host. Still useful for dev/testing. + statime: + build: + context: . + dockerfile: Dockerfile + image: ntp_timeturner:latest + container_name: statime + cap_add: + - NET_ADMIN + - NET_RAW + - SYS_TIME + command: ["statime", "-i", "eth0"] + # Expose standard PTP ports (udp/319, udp/320) + ports: + - "319:319/udp" + - "320:320/udp" + restart: unless-stopped