Docker build and deploy

This commit is contained in:
ChristianVisintin
2020-12-14 15:35:41 +01:00
parent 18aacef89f
commit 3ea8188805
3 changed files with 42 additions and 0 deletions

3
.gitignore vendored
View File

@@ -13,3 +13,6 @@
**/*.rs.bk
# End of https://www.gitignore.io/api/rust
*.rpm
*.deb

20
dist/build/deploy.sh vendored Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: deploy.sh <version>"
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 $?

19
dist/build/x86_64/Dockerfile vendored Normal file
View File

@@ -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"]