Skip to content

Commit

Permalink
automatic building
Browse files Browse the repository at this point in the history
  • Loading branch information
fritshoogland-yugabyte committed May 4, 2023
1 parent ce0471f commit 827f169
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <fhoogland@yugabyte.com>"
maintainer = "Frits Hoogland <fhoogland@yugabyte.com>"
assets = [
["target/release/dsar", "/usr/local/bin/", "755"]
]
24 changes: 24 additions & 0 deletions util/Dockerfile.build_alma_8
Original file line number Diff line number Diff line change
@@ -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/* /
25 changes: 25 additions & 0 deletions util/Dockerfile.build_alma_9
Original file line number Diff line number Diff line change
@@ -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/* /

24 changes: 24 additions & 0 deletions util/Dockerfile.build_centos_7
Original file line number Diff line number Diff line change
@@ -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/* /
24 changes: 24 additions & 0 deletions util/Dockerfile.build_ubuntu_2204
Original file line number Diff line number Diff line change
@@ -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 /

4 changes: 4 additions & 0 deletions util/build_linux_packages.sh
Original file line number Diff line number Diff line change
@@ -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 .
4 changes: 4 additions & 0 deletions util/build_osx_package.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 827f169

Please sign in to comment.