|
| 1 | +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} |
| 2 | +ARG BASE=docker-config-engine-bookworm-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} |
| 3 | + |
| 4 | +FROM $BASE AS builder |
| 5 | + |
| 6 | +# Update apt's cache of available packages |
| 7 | +RUN apt-get update && apt-get install -y \ |
| 8 | + build-essential |
| 9 | + |
| 10 | +# Install Rust/Cargo via rustup |
| 11 | +ARG RUST_ROOT=/usr/.cargo |
| 12 | +RUN RUSTUP_HOME=$RUST_ROOT CARGO_HOME=$RUST_ROOT bash -c \ |
| 13 | + 'curl --proto "=https" -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.79.0 -y' |
| 14 | +ENV RUSTUP_HOME=$RUST_ROOT |
| 15 | +ENV PATH $PATH:$RUST_ROOT/bin |
| 16 | + |
| 17 | +# Copy watchdog source into /watchdog |
| 18 | +WORKDIR /watchdog |
| 19 | +COPY watchdog/ ./ |
| 20 | + |
| 21 | +# Build from within /watchdog |
| 22 | +RUN cargo build --release |
| 23 | + |
| 24 | +FROM $BASE AS base |
| 25 | + |
| 26 | +ARG docker_container_name |
| 27 | +ARG image_version |
| 28 | +RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf |
| 29 | + |
| 30 | +ENV DEBIAN_FRONTEND=noninteractive |
| 31 | +ENV IMAGE_VERSION=$image_version |
| 32 | + |
| 33 | +# Copy supervisord.conf into final stage |
| 34 | +COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] |
| 35 | + |
| 36 | +# Copy the compiled Rust binary from the builder stage |
| 37 | +COPY --from=builder /watchdog/target/release/telemetry_watchdog /usr/bin/telemetry_watchdog |
| 38 | +RUN chmod +x /usr/bin/telemetry_watchdog |
| 39 | + |
| 40 | +FROM $BASE |
| 41 | + |
| 42 | +RUN --mount=type=bind,from=base,target=/changes-to-image rsync -axAX --no-D --exclude=/sys --exclude=/proc --exclude=/dev --exclude=resolv.conf /changes-to-image/ / |
| 43 | + |
| 44 | +# Make apt-get non-interactive |
| 45 | +ENV DEBIAN_FRONTEND=noninteractive |
| 46 | + |
| 47 | +# Pass the image_version to container |
| 48 | +ENV IMAGE_VERSION=$image_version |
| 49 | + |
| 50 | +ENTRYPOINT ["/usr/local/bin/supervisord"] |
0 commit comments