Browse Source

Merge pull request #101 from nka11/build_docker_image

Resources for building a docker image
pull/104/head
Rodolphe Bréard 1 year ago
committed by GitHub
parent
commit
53c5933190
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .dockerignore
  2. 4
      README.md
  3. 14
      contrib/docker/Dockerfile
  4. 45
      contrib/docker/build-docker-image.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. 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 ### Advanced options
You can specify a space or comma separated list of features to activate in the `FEATURE` variable. The possible features are: 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."
Loading…
Cancel
Save