# Build stage for Linux FROM rust:1-bookworm as linux-builder # Install dependencies RUN apt-get update && \ apt-get install -y apt-transport-https && \ apt-get install -y \ libssl-dev \ pkg-config \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY ./WatcherAgent/ . COPY ./WatcherAgent/.env /app/.env # Build for Linux RUN cargo build --release --target x86_64-unknown-linux-gnu # Setze Berechtigungen für das Binary RUN chmod +x /app/target/x86_64-unknown-linux-gnu/release/$BINARY_NAME # Final Linux image FROM debian:bookworm-slim RUN apt-get update && \ apt-get install -y apt-transport-https && \ apt-get install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* # Make binary name configurable ARG BINARY_NAME ENV BINARY_NAME=${BINARY_NAME:-WatcherAgent} COPY --from=linux-builder /app/target/x86_64-unknown-linux-gnu/release/${BINARY_NAME} /usr/local/bin/ # Health check HEALTHCHECK --interval=30s --timeout=3s \ cmd /usr/local/bin/${BINARY_NAME} healthcheck || exit 1 ENTRYPOINT ["/bin/sh", "-c", "/usr/local/bin/${BINARY_NAME}"]