Files
NLnetLabs-krill/Dockerfile
T
ximon18andGitHub d00f9617d0 Base the Docker image on Alpine Linux. (#179)
Use Alpine instead of Ubuntu, for a smaller Docker image and consistency with NLnet Labs Routinator.
2020-01-29 16:11:01 +01:00

53 lines
1.5 KiB
Docker

#
# Make the base image configurable so that the E2E test can use a base image
# with a prepopulated Cargo build cache to accelerate the build process.
# Use Ubuntu 16.04 because this is what the Travis CI Krill build uses.
#
ARG BASE_IMG=alpine:3.11
#
# -- stage 1: build krill and krillc
#
FROM ${BASE_IMG} AS build
RUN apk add rust cargo openssl-dev
WORKDIR /tmp/krill
COPY . .
RUN cargo build --target x86_64-alpine-linux-musl --release
#
# -- stage 2: create an image containing just the binaries, configs &
# scripts needed to run Krill, and not the things needed to build
# it.
#
FROM alpine:3.11
COPY --from=build /tmp/krill/target/x86_64-alpine-linux-musl/release/krill /usr/local/bin/
COPY --from=build /tmp/krill/target/x86_64-alpine-linux-musl/release/krillc /usr/local/bin/
# Build variables for uid and guid of user to run container
ARG RUN_USER=krill
ARG RUN_USER_UID=1012
ARG RUN_USER_GID=1012
RUN apk add bash libgcc openssl tzdata util-linux
RUN addgroup -g ${RUN_USER_GID} ${RUN_USER} && \
adduser -D -u ${RUN_USER_UID} -G ${RUN_USER} ${RUN_USER}
# Create the data directory structure and install a config file that uses it
WORKDIR /var/krill/data
COPY docker/krill.conf .
RUN chown -R ${RUN_USER}: .
# Install a Docker entrypoint script that will be executed when the container
# runs
COPY docker/entrypoint.sh /opt/
RUN chown ${RUN_USER}: /opt/entrypoint.sh
EXPOSE 3000/tcp
ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["krill", "-c", "/var/krill/data/krill.conf"]