From 3ea8188805f8684aeeecd2a5d8e0204875b655e4 Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Mon, 14 Dec 2020 15:35:41 +0100 Subject: [PATCH] Docker build and deploy --- .gitignore | 3 +++ dist/build/deploy.sh | 20 ++++++++++++++++++++ dist/build/x86_64/Dockerfile | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100755 dist/build/deploy.sh create mode 100644 dist/build/x86_64/Dockerfile diff --git a/.gitignore b/.gitignore index 24397ca..b03583c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ **/*.rs.bk # End of https://www.gitignore.io/api/rust + +*.rpm +*.deb diff --git a/dist/build/deploy.sh b/dist/build/deploy.sh new file mode 100755 index 0000000..d286f35 --- /dev/null +++ b/dist/build/deploy.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: deploy.sh " + exit 1 +fi + +VERSION=$1 + +# Build x86_64 +cd x86_64/ +docker build --tag termscp-${VERSION}-x86_64 . +# Get pkgs +cd - +# Create container +CONTAINER_NAME=$(docker create termscp-${VERSION}-x86_64 termscp-${VERSION}-x86_64) +docker cp ${CONTAINER_NAME}:/usr/src/TermSCP/target/debian/termscp_${VERSION}_amd64.deb . +docker cp ${CONTAINER_NAME}:/usr/src/TermSCP/target/release/rpmbuild/RPMS/x86_64/termscp-${VERSION}-1.x86_64.rpm . + +exit $? diff --git a/dist/build/x86_64/Dockerfile b/dist/build/x86_64/Dockerfile new file mode 100644 index 0000000..4e754da --- /dev/null +++ b/dist/build/x86_64/Dockerfile @@ -0,0 +1,19 @@ +FROM rust:1.48.0 AS builder + +WORKDIR /usr/src/ +# Add toolchains +RUN rustup target add x86_64-unknown-linux-gnu +# Install dependencies +RUN apt update && apt install -y rpm +# Clone repository +RUN git clone https://github.com/ChristianVisintin/TermSCP.git +# Set workdir to termscp +WORKDIR /usr/src/TermSCP/ +# Install cargo RPM/Deb +RUN cargo install cargo-deb cargo-rpm +# Build for x86_64 +RUN cargo build --release --target x86_64-unknown-linux-gnu +# Build pkgs +RUN cargo deb && cargo rpm init && cargo rpm build + +CMD ["sh"]