FROM blackdex/rust-musl:x86_64-musl-stable-1.78.0 AS build SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN apt-get update && apt-get install -y \ rpm \ dpkg-dev \ fakeroot \ build-essential COPY Cargo.toml rustfmt.toml /project/ COPY src /project/src WORKDIR /project ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse RUN cargo build --release --target x86_64-unknown-linux-musl RUN cp /project/target/x86_64-unknown-linux-musl/release/check_jitter /project/check_jitter && \ strip --strip-all /project/check_jitter COPY opt /project/opt COPY debian/DEBIAN/ /root/debbuild/DEBIAN/ RUN grep '^version =' Cargo.toml | awk -F\" '{print $2}' > /tmp/version.txt RUN mkdir -p /root/debbuild/usr/bin/ && \ mkdir -p /root/debbuild/opt/itrs/infrastructure-agent/plugins && \ mkdir -p /root/debbuild/opt/itrs/infrastructure-agent/cfg/custom && \ cp check_jitter /root/debbuild/opt/itrs/infrastructure-agent/plugins/check_jitter && \ chown root:root /root/debbuild/opt/itrs/infrastructure-agent/plugins/check_jitter && \ chmod 550 /root/debbuild/opt/itrs/infrastructure-agent/plugins/check_jitter && \ cp -r /project/opt/itrs/infrastructure-agent/cfg/custom/check_jitter.yml /root/debbuild/opt/itrs/infrastructure-agent/cfg/custom/check_jitter.yml && \ chown root:root /root/debbuild/opt/itrs/infrastructure-agent/cfg/custom/check_jitter.yml && \ chmod 400 /root/debbuild/opt/itrs/infrastructure-agent/cfg/custom/check_jitter.yml && \ version=$(cat /tmp/version.txt) && \ sed -i "s/{{VERSION}}/$version/" /root/debbuild/DEBIAN/control.template && \ mv /root/debbuild/DEBIAN/control.template /root/debbuild/DEBIAN/control && \ dpkg-deb --build /root/debbuild && \ cp /root/debbuild.deb /opsview-check-jitter_$version-1_amd64.deb COPY rhel /project/rhel/ RUN version=$(cat /tmp/version.txt) && \ mkdir -p /root/rpmbuild/{SPECS,SOURCES} && \ mkdir -p /tmp/opsview-check-jitter-$version && \ cp rhel/opsview-check-jitter.spec.template /root/rpmbuild/SPECS/opsview-check-jitter.spec && \ cp Cargo.toml /tmp/opsview-check-jitter-$version/ && \ cp rustfmt.toml /tmp/opsview-check-jitter-$version/ && \ cp -r src /tmp/opsview-check-jitter-$version/ && \ cp -r opt /tmp/opsview-check-jitter-$version/ && \ tar czvf /root/rpmbuild/SOURCES/opsview-check-jitter-$version.tar.gz -C /tmp opsview-check-jitter-$version && \ sed -i "s/{{VERSION}}/$version/" /root/rpmbuild/SPECS/opsview-check-jitter.spec && \ sed -i "s/{{RELEASE_DIR}}/\/project/" /root/rpmbuild/SPECS/opsview-check-jitter.spec && \ sed -i "s/{{CFG_DIR}}/\/project\/opt\/itrs\/infrastructure-agent\/cfg/" /root/rpmbuild/SPECS/opsview-check-jitter.spec && \ rpmbuild -bb /root/rpmbuild/SPECS/opsview-check-jitter.spec && \ cp /root/rpmbuild/RPMS/x86_64/opsview-check-jitter-*.x86_64.rpm /opsview-check-jitter-$version-1.x86_64.rpm FROM scratch AS bin COPY --from=build /project/check_jitter /check_jitter-x86_64-unknown-linux-musl COPY --from=build /opsview-check-jitter-*.x86_64.rpm / COPY --from=build /opsview-check-jitter_*.deb /