Last active
November 4, 2019 03:28
-
-
Save olix0r/cd34cdb9730e2e63a85e725135617011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 0 ]; then | |
echo "usage: $0 [cargo options]" >&2 | |
exit 64 | |
fi | |
if [ ! -r Cargo.lock ]; then | |
echo "Not a cargo project: missing Cargo.lock" >&2 | |
exit 1 | |
fi | |
# buildx is still experimental by default. | |
export DOCKER_CLI_EXPERIMENTAL=enabled | |
# We don't actually need to (necessarily) push artifacts, but we need a valid | |
# repo we own. We sha the lockfile to bust the cache when dependencies change. | |
CACHE_REF="olix0r/cache:$(sha256sum Cargo.lock |cut -f1 -d' ')" | |
docker buildx build --load --cache-from="type=registry,ref=$CACHE_REF" --cache-to="type=registry,ref=$CACHE_REF" -f- . <<EOF | |
# syntax=docker/dockerfile:experimental | |
FROM rust:1.38.0-buster | |
COPY . . | |
RUN --mount=type=cache,target=\$CARGO_HOME --mount=type=cache,target=./target cargo $@ | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment