diff --git a/Cargo.lock b/Cargo.lock index f70be28..063ee82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2100,7 +2100,7 @@ dependencies = [ [[package]] name = "zeronsd" -version = "0.4.3" +version = "0.5.0" dependencies = [ "anyhow", "async-trait", diff --git a/Dockerfile b/Dockerfile index d05b713..b47de8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest as rustenv +FROM debian:latest as rustenv ARG IS_LOCAL=0 ARG VERSION=main diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 02527ac..5262aab 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -8,15 +8,20 @@ FROM alpine:latest as builder -RUN apk add rust -RUN apk add cargo +RUN apk add gcc +RUN apk add libgcc +RUN apk add musl-dev RUN apk add openssl RUN apk add openssl-dev +RUN apk add curl + +RUN curl -sSL sh.rustup.rs >/usr/local/bin/rustup-dl && chmod +x /usr/local/bin/rustup-dl && /usr/local/bin/rustup-dl -y --default-toolchain stable COPY . /zeronsd WORKDIR /zeronsd -RUN cargo install --path . +ENV PATH=/root/.cargo/bin:${PATH} +RUN . /root/.cargo/env && cargo install --path . FROM alpine:latest diff --git a/Dockerfile.packages b/Dockerfile.packages index cadc928..59235d8 100644 --- a/Dockerfile.packages +++ b/Dockerfile.packages @@ -1,3 +1,8 @@ -FROM rust +FROM debian:latest as rustenv -RUN cargo install cargo-deb cargo-generate-rpm +RUN apt-get update -qq && apt-get install curl pkg-config build-essential libssl1.1 ca-certificates -y && apt-get autoclean -y && apt-get clean -y +RUN curl -sSL sh.rustup.rs >/usr/local/bin/rustup-dl && chmod +x /usr/local/bin/rustup-dl && /usr/local/bin/rustup-dl -y --default-toolchain stable + +FROM rustenv as buildenv + +RUN . /root/.cargo/env && cargo install cargo-deb cargo-generate-rpm diff --git a/Dockerfile.ubi b/Dockerfile.ubi new file mode 100644 index 0000000..568d84a --- /dev/null +++ b/Dockerfile.ubi @@ -0,0 +1,7 @@ +# vim: ft=dockerfile +FROM redhat/ubi8 + +RUN dnf install openssl-devel gcc -y +RUN curl -sSL sh.rustup.rs >/tmp/rustup.sh && bash /tmp/rustup.sh -y +ENV PATH=${PATH}:${HOME}/.cargo/bin +RUN . /root/.cargo/env && cargo install cargo-generate-rpm diff --git a/Makefile b/Makefile index 206eb3c..143dbee 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,12 @@ docker-image-push: docker-image-package packages: make docker-image-package mkdir -p target/packages + docker build -f Dockerfile.ubi -t zeronsd-packages-ubi . + docker run -it -v ${PWD}:/code -w /code --rm zeronsd-packages-ubi bash -c ". /root/.cargo/env && cargo build --release && cargo generate-rpm && mv /code/target/generate-rpm/*.rpm /code/target/packages" docker build -f Dockerfile.ubuntu -t zeronsd-packages-ubuntu . docker run -it -v ${PWD}:/code -w /code --rm zeronsd-packages-ubuntu bash -c "cargo deb --deb-version ${CARGO_VERSION}-ubuntu22 && mv /code/target/debian/*.deb /code/target/packages" docker build -f Dockerfile.packages -t zeronsd-packages . - docker run -it -v ${PWD}:/code -w /code --rm zeronsd-packages bash -c "cargo deb && cargo-generate-rpm && mv /code/target/debian/*.deb /code/target/generate-rpm/*.rpm /code/target/packages " + docker run -it -v ${PWD}:/code -w /code --rm zeronsd-packages bash -c ". /root/.cargo/env && cargo deb && mv /code/target/debian/*.deb /code/target/packages" make packages-out packages-out: @@ -61,9 +63,8 @@ clean: sudo rm -rf target cargo clean -test-packages: clean - make packages - docker run -v ${PWD}:/code --rm -it centos rpm -ivh /code/target/packages/\*.rpm +test-packages: clean packages + docker run -v ${PWD}:/code --rm -it redhat/ubi8 bash -c "rpm -ivh /code/target/packages/\*.rpm" docker run -v ${PWD}:/code --rm -it debian:latest bash -c "apt update -qq && apt install libssl1.1 && dpkg -i /code/target/packages/zeronsd_${CARGO_VERSION}_amd64.deb" docker run -v ${PWD}:/code --rm -it ubuntu:focal bash -c "apt update -qq && apt install libssl1.1 && dpkg -i /code/target/packages/zeronsd_${CARGO_VERSION}_amd64.deb" docker run -v ${PWD}:/code --rm -it ubuntu:jammy bash -c "apt update -qq && apt install libssl3 && dpkg -i /code/target/packages/zeronsd_${CARGO_VERSION}-ubuntu22_amd64.deb"