From 827f1696aa20e54b714bdd04d66fd8b39e395cb1 Mon Sep 17 00:00:00 2001 From: Frits Hoogland Date: Thu, 4 May 2023 15:50:04 +0200 Subject: [PATCH] automatic building --- Cargo.toml | 15 +++++++++++++++ util/Dockerfile.build_alma_8 | 24 ++++++++++++++++++++++++ util/Dockerfile.build_alma_9 | 25 +++++++++++++++++++++++++ util/Dockerfile.build_centos_7 | 24 ++++++++++++++++++++++++ util/Dockerfile.build_ubuntu_2204 | 24 ++++++++++++++++++++++++ util/build_linux_packages.sh | 4 ++++ util/build_osx_package.sh | 4 ++++ 7 files changed, 120 insertions(+) create mode 100644 util/Dockerfile.build_alma_8 create mode 100644 util/Dockerfile.build_alma_9 create mode 100644 util/Dockerfile.build_centos_7 create mode 100644 util/Dockerfile.build_ubuntu_2204 create mode 100755 util/build_linux_packages.sh create mode 100755 util/build_osx_package.sh diff --git a/Cargo.toml b/Cargo.toml index 6b08601..f4779e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ name = "dsar" version = "0.1.0" edition = "2021" +license = "apache-2.0" +description = "A utility to get sar like functionality using node_exporter endpoints of multiple machines." # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,3 +18,16 @@ prometheus-parse = "0.2.4" rayon = "1.7.0" reqwest = { version = "0.11.16", features = ["blocking"] } tokio = { version = "1.27.0", features = ["full"] } + +[package.metadata.generate-rpm] +assets = [ + { source = "target/release/dsar", dest = "/usr/local/bin/dsar", mode="0755" } +] +release = "1.el8" + +[package.metadata.deb] +copyright = "2021, Frits Hoogland " +maintainer = "Frits Hoogland " +assets = [ + ["target/release/dsar", "/usr/local/bin/", "755"] +] \ No newline at end of file diff --git a/util/Dockerfile.build_alma_8 b/util/Dockerfile.build_alma_8 new file mode 100644 index 0000000..77ab89b --- /dev/null +++ b/util/Dockerfile.build_alma_8 @@ -0,0 +1,24 @@ +FROM almalinux/8-base as builder + +# setup source directory +WORKDIR /usr/src/dsar +COPY . . + +# prepare operating system and install rust +RUN yum update -y +RUN yum install -y openssl-devel gcc +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/root/.cargo/bin + +# build executable +RUN cargo build --release +RUN strip -s target/release/dsar + +# generate rpm +RUN cargo install cargo-generate-rpm +RUN cargo generate-rpm -s 'release = "el.8"' +RUN ls -ls /usr/src/dsar/target/generate-rpm/* + +FROM scratch as export-stage +# output file +COPY --from=builder /usr/src/dsar/target/generate-rpm/* / diff --git a/util/Dockerfile.build_alma_9 b/util/Dockerfile.build_alma_9 new file mode 100644 index 0000000..88975e0 --- /dev/null +++ b/util/Dockerfile.build_alma_9 @@ -0,0 +1,25 @@ +FROM almalinux/9-base as builder + +# setup source directory +WORKDIR /usr/src/dsar +COPY . . + +# prepare operating system and install rust +RUN yum update -y +RUN yum install -y openssl-devel gcc +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/root/.cargo/bin + +# build executable +RUN cargo build --release +RUN strip -s target/release/dsar + +# generate rpm +RUN cargo install cargo-generate-rpm +RUN cargo generate-rpm -s 'release = "el.9"' +RUN ls -ls /usr/src/dsar/target/generate-rpm/* + +FROM scratch as export-stage +# output file +COPY --from=builder /usr/src/dsar/target/generate-rpm/* / + diff --git a/util/Dockerfile.build_centos_7 b/util/Dockerfile.build_centos_7 new file mode 100644 index 0000000..4186110 --- /dev/null +++ b/util/Dockerfile.build_centos_7 @@ -0,0 +1,24 @@ +FROM centos:centos7 as builder + +# setup source directory +WORKDIR /usr/src/dsar +COPY . . + +# prepare operating system and install rust +RUN yum update -y +RUN yum install -y openssl-devel gcc +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/root/.cargo/bin + +# build executable +RUN cargo build --release +RUN strip -s target/release/dsar + +# generate rpm +RUN cargo install cargo-generate-rpm +RUN cargo generate-rpm --payload-compress=gzip -s 'release = "el.7"' +RUN ls -ls /usr/src/dsar/target/generate-rpm/* + +FROM scratch as export-stage +# output file +COPY --from=builder /usr/src/dsar/target/generate-rpm/* / diff --git a/util/Dockerfile.build_ubuntu_2204 b/util/Dockerfile.build_ubuntu_2204 new file mode 100644 index 0000000..8f81a51 --- /dev/null +++ b/util/Dockerfile.build_ubuntu_2204 @@ -0,0 +1,24 @@ +FROM ubuntu:jammy as builder + +# setup source directory +WORKDIR /usr/src/dsar +COPY . . + +# prepare operating system and install rust +RUN apt update && apt upgrade -y +RUN apt-get install -y curl gcc libssl-dev pkg-config +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/root/.cargo/bin + +# build executable +RUN cargo build --release +RUN strip -s target/release/dsar + +# generate rpm +RUN cargo install cargo-deb +RUN cargo deb + +# output file +FROM scratch as export-stage +COPY --from=builder /usr/src/dsar/target/debian/*deb / + diff --git a/util/build_linux_packages.sh b/util/build_linux_packages.sh new file mode 100755 index 0000000..f571426 --- /dev/null +++ b/util/build_linux_packages.sh @@ -0,0 +1,4 @@ +docker build --rm --output . --file util/Dockerfile.build_centos_7 . +docker build --rm --output . --file util/Dockerfile.build_alma_8 . +docker build --rm --output . --file util/Dockerfile.build_alma_9 . +docker build --rm --output . --file util/Dockerfile.build_ubuntu_2204 . diff --git a/util/build_osx_package.sh b/util/build_osx_package.sh new file mode 100755 index 0000000..d91dc9b --- /dev/null +++ b/util/build_osx_package.sh @@ -0,0 +1,4 @@ +cargo build --release +strip -S target/release/dsar +CARGO_APP_VERSION=$(grep ^version Cargo.toml | sed 's/.*"\(.*\)"/\1/') +tar czvf dsar-osx-intel-v${CARGO_APP_VERSION}-1.tar.gz -C target/release dsar