feat: add Docker setup with Dockerfile and docker-compose

Co-authored-by: aider (openai/gpt-5) <aider@aider.chat>
This commit is contained in:
Chaos Rogers 2025-10-21 22:51:25 +01:00
parent 5ba0421f76
commit 4d34f11b87
3 changed files with 95 additions and 0 deletions

44
Dockerfile Normal file
View file

@ -0,0 +1,44 @@
# 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 Cargo.lock ./
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 real binaries
COPY . .
RUN cargo build --release --bin ntp_timeturner --bin ptp_probe
# Runtime image
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libudev1 \
ca-certificates \
tzdata \
&& rm -rf /var/lib/apt/lists/*
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 static ./static
ENV RUST_LOG=info
EXPOSE 8080
# Default to running the main server
CMD ["ntp_timeturner"]