Browse Source

Merge pull request #23 from dbrgn/docker-build

Add build-docker.sh script
pull/31/head
Rodolphe Bréard 4 years ago
committed by GitHub
parent
commit
669f13dbce
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      README.md
  2. 48
      build-docker.sh

2
README.md

@ -74,6 +74,8 @@ $ make
$ make install $ make install
``` ```
To build ACMEd and tacd inside a temporary Docker container, use the `build-docker.sh` helper script. It currently supports Debian Buster / Stretch.
## Frequently Asked Questions ## Frequently Asked Questions

48
build-docker.sh

@ -0,0 +1,48 @@
#!/bin/bash
set -euo pipefail
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Parse command line args
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <target>"
echo "Supported targets: stretch, buster"
exit 1
fi
if [ "$1" == "buster" ]; then
TARGET=buster
elif [ "$1" == "stretch" ]; then
TARGET=stretch
else
echo "Invalid target: $1"
exit 1
fi
# Determine image
IMAGE=rust:1-$TARGET
function log {
echo -e "\033[32;1m==> ${1}\033[0m"
}
log "Pulling image $IMAGE..."
docker pull $IMAGE
log "Starting container..."
CID=$(docker run --rm -td $IMAGE)
log "Copying project files..."
docker cp "$DIR" "$CID":/code/
log "Starting build..."
docker exec "$CID" /bin/bash -c "cd /code && cargo build --release"
log "Copying binaries..."
mkdir -p target/docker/$TARGET/
docker cp "$CID":/code/target/release/acmed target/docker/$TARGET/
docker cp "$CID":/code/target/release/tacd target/docker/$TARGET/
log "Stopping and removing container..."
docker stop "$CID"
log "Done! Find your binaries in the target/docker/$TARGET/ directory."
Loading…
Cancel
Save