From 4959d3188a8864597adb9b9bff2827e08c4a4ab5 Mon Sep 17 00:00:00 2001 From: Eric Kidd Date: Tue, 24 Oct 2017 09:33:56 -0400 Subject: [PATCH] Fix `build-release` example to work on current TravisCI The Travis UUID has been changed from 1000 to 2000, so now making images is considerably more annoying than before. --- README.md | 13 +++++++++++++ examples/build-release | 12 ++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e8a93d0..87d7697 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,19 @@ deploy: Next, copy [`build-release`](./examples/build-release) into your project and run `chmod +x build-release`. +Finally, add a `Dockerfile` to perform the actual build: + +```rust +FROM ekidd/rust-musl-builder + +# We need to add the source code to the image because `rust-musl-builder` +# assumes a UID of 1000, but TravisCI has switched to 2000. +ADD . ./ +RUN sudo chown -R rust:rust . + +CMD cargo build --release +``` + When you push a new tag to your project, `build-release` will automatically build new Linux binaries using `rust-musl-builder`, and new Mac binaries with Cargo, and it will upload both to the GitHub releases page for your repository. For a working example, see [faradayio/cage][cage]. diff --git a/examples/build-release b/examples/build-release index 76e31fd..1d1536e 100755 --- a/examples/build-release +++ b/examples/build-release @@ -16,15 +16,15 @@ set -euo pipefail -rust-musl-builder() { - docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder "$@" -} - case `uname -s` in Linux) echo "Building static binaries using ekidd/rust-musl-builder" - rust-musl-builder cargo build --release - zip -j "$1"-"$2".zip target/x86_64-unknown-linux-musl/release/"$1" + docker build -t build-"$1"-image . + docker run -it --name build-"$1" build-"$1"-image + docker cp build-"$1":/home/rust/src/target/x86_64-unknown-linux-musl/release/"$1" "$1" + docker rm build-"$1" + docker rmi build-"$1"-image + zip "$1"-"$2".zip "$1" ;; *) echo "Building standard release binaries"