Browse Source

Merge branch 'main' of github.com:breard-r/acmed

pull/104/head
Rodolphe Bréard 6 months ago
parent
commit
f9def02946
  1. 2
      .dockerignore
  2. 4
      README.md
  3. 14
      contrib/docker/Dockerfile
  4. 45
      contrib/docker/build-docker-image.sh
  5. 4
      contrib/docker/build-docker.sh

2
.dockerignore

@ -0,0 +1,2 @@
Dockerfile
contrib/docker

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 ca-certificates && 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"]

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

@ -0,0 +1,45 @@
#!/bin/bash
# ACMED certificate watcher and renewer daemon.
# Helper script to build debian based docker image
# Author: Nicolas Karageuzian
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."

4
contrib/docker/build-docker.sh

@ -31,8 +31,10 @@ docker pull $IMAGE
log "Starting container..."
CID=$(docker run --rm -td $IMAGE)
docker exec "$CID" mkdir /code
log "Copying project files..."
docker cp "$DIR" "$CID":/code/
docker cp "$DIR/." "$CID":/code/
log "Starting build..."
docker exec "$CID" /bin/bash -c "cd /code && cargo build --release"

Loading…
Cancel
Save