Browse Source

Add resources to build a docker image

pull/101/head
Nicolas K 7 months ago
parent
commit
b52ab46be4
  1. 4
      README.md
  2. 14
      contrib/docker/Dockerfile
  3. 41
      contrib/docker/build-docker-image.sh

4
README.md

@ -92,6 +92,10 @@ $ make install
To build ACMEd and tacd inside a temporary Docker container, use the `contrib/docker/build-docker.sh` helper script. It currently supports Debian Buster / Stretch.
You can also build a container image for some k8s deployement, use the `contrib/docker/build-docker-image.sh` script. It supports the same targets as the build-docker.sh script.
When build succeed, you can start the container with `docker run --rm -v /path/to/conf/dir:/etc/acmed acmed:buster`.
### Advanced options
You can specify a space or comma separated list of features to activate in the `FEATURE` variable. The possible features are:

14
contrib/docker/Dockerfile

@ -0,0 +1,14 @@
ARG TARGET=buster
FROM rust:1-$TARGET as builder
WORKDIR /code
COPY . .
RUN cargo build --release
FROM debian:$TARGET-slim
RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /code/target/release/acmed /usr/local/bin/acmed
COPY --from=builder /code/target/release/tacd /usr/local/bin/tacd
CMD ["/usr/local/bin/acmed", "-f", "--log-stderr"]

41
contrib/docker/build-docker-image.sh

@ -0,0 +1,41 @@
#!/bin/bash
set -euo pipefail
DIR="$( cd "$( dirname "$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"
}
# This or commit Dockerfile at project root
log "Prepare docker build"
cp $( dirname "$0" )/Dockerfile $DIR
cd $DIR
log "Build docker image"
docker build -t acmed:$TARGET --build-arg TARGET=$TARGET .
log "Successfully built image, Cleanup"
rm Dockerfile
log "Done! Find your binaries in the /usr/local/bin directory of image acmed:$TARGET."
Loading…
Cancel
Save