Dockerfile 1.49 KB
Newer Older
1 2 3 4
ARG KNOT_BRANCH=2.7

# first build stage, it will not persist in the final image
FROM registry.labs.nic.cz/knot/respdiff/knot-resolver-buildenv:knot-$KNOT_BRANCH as intermediate
5

6 7 8 9
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG SSH_PRIVATE_KEY
ARG GIT_SHA

10 11 12 13 14 15
RUN mkdir /root/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
RUN chmod 0600 /root/.ssh/id_rsa

RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan gitlab.labs.nic.cz >> /root/.ssh/known_hosts
16 17

RUN git clone --recursive -j8 https://gitlab.labs.nic.cz/knot/knot-resolver.git /var/opt/knot-resolver
18 19
RUN \
	cd /var/opt/knot-resolver; \
20
	git checkout "${GIT_SHA}" -- || (\
21 22 23 24
		cd /var/opt; \
		rm -rf /var/opt/knot-resolver; \
		git clone --recursive -j8 git@gitlab.labs.nic.cz:knot/knot-resolver-security.git /var/opt/knot-resolver; \
		cd /var/opt/knot-resolver; \
25
		git checkout "${GIT_SHA}" --)
26 27 28


# actual image
29
FROM registry.labs.nic.cz/knot/respdiff/knot-resolver-buildenv:knot-$KNOT_BRANCH
30
MAINTAINER Knot Resolver <knot-resolver@labs.nic.cz>
31
ARG CFLAGS
32 33

COPY --from=intermediate /var/opt/knot-resolver /var/opt/knot-resolver
34
WORKDIR /var/opt/knot-resolver
35

36
RUN mkdir .install
37
RUN make PREFIX=/var/opt/knot-resolver/.install LDFLAGS="-Wl,-rpath=/var/opt/knot-resolver/.install/lib" CFLAGS="${CFLAGS}"
38 39
RUN make install PREFIX=/var/opt/knot-resolver/.install

40 41 42
RUN mkdir /log

CMD /var/opt/knot-resolver/.install/sbin/kresd -c /etc/knot-resolver/kresd.conf -K /etc/knot-resolver/root.keys -v -f 1 /dev/shm >> /log/kresd.log