add multi stage build to netdisco-base
This commit is contained in:
@@ -5,11 +5,11 @@ FROM docker.io/netdisco/netdisco-base:${TAG}-base
|
|||||||
LABEL org.netdisco.maintainer="The Netdisco Project"
|
LABEL org.netdisco.maintainer="The Netdisco Project"
|
||||||
LABEL org.netdisco.version=${TAG}
|
LABEL org.netdisco.version=${TAG}
|
||||||
|
|
||||||
WORKDIR $NETDISCO_HOME/netdisco-mibs
|
WORKDIR /home/netdisco/netdisco-mibs
|
||||||
RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/tags | \
|
RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/tags | \
|
||||||
jq '.[]|.tarball_url|select(test("tarball/\\d+\\.\\d+$"))' | \
|
jq '.[]|.tarball_url|select(test("tarball/\\d+\\.\\d+$"))' | \
|
||||||
sort -rg | head -n1 | xargs -n1 curl -sL | tar --strip-components=1 -zxf -
|
sort -rg | head -n1 | xargs -n1 curl -sL | tar --strip-components=1 -zxf -
|
||||||
|
|
||||||
WORKDIR $NETDISCO_HOME
|
WORKDIR /home/netdisco
|
||||||
ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"]
|
ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"]
|
||||||
CMD ["foreground"]
|
CMD ["foreground"]
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
# vim: ft=Dockerfile
|
# vim: ft=Dockerfile
|
||||||
ARG TAG=master
|
ARG TAG=master
|
||||||
FROM debian:stable-slim
|
FROM debian:stable-slim as netdisco-build-image
|
||||||
|
|
||||||
LABEL org.netdisco.maintainer="The Netdisco Project"
|
|
||||||
LABEL org.netdisco.version=${TAG}
|
|
||||||
|
|
||||||
RUN bash -c 'mkdir -p /usr/share/man/man{1..8}' && \
|
RUN bash -c 'mkdir -p /usr/share/man/man{1..8}' && \
|
||||||
apt-get -yq update && \
|
apt-get -yq update && \
|
||||||
@@ -19,28 +16,55 @@ RUN bash -c 'mkdir -p /usr/share/man/man{1..8}' && \
|
|||||||
libnet-ldap-perl \
|
libnet-ldap-perl \
|
||||||
libsnmp-perl \
|
libsnmp-perl \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
postgresql-client && \
|
postgresql-client
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ENV NETDISCO_HOME "/home/netdisco"
|
ENV HOME "/home/netdisco"
|
||||||
RUN groupadd -r netdisco -g 901 && \
|
RUN groupadd -r netdisco -g 901 && \
|
||||||
useradd -u 901 -r -p x -g netdisco -m -d $NETDISCO_HOME -s /bin/bash -c "netdisco user" netdisco
|
useradd -u 901 -r -p x -g netdisco -m -d $HOME -s /bin/bash -c "netdisco user" netdisco
|
||||||
|
|
||||||
USER netdisco:netdisco
|
USER netdisco:netdisco
|
||||||
RUN curl -sL https://api.github.com/repos/netdisco/netdisco/tags | \
|
RUN curl -sL https://api.github.com/repos/netdisco/netdisco/tags | \
|
||||||
jq '.[]|.name|select(test("^\\d+\\.\\d+$"))|"https://github.com/netdisco/netdisco.git@"+.' | \
|
jq '.[]|.name|select(test("^\\d+\\.\\d+$"))|"https://github.com/netdisco/netdisco.git@"+.' | \
|
||||||
sort -rg | head -n1 | \
|
sort -rg | head -n1 | \
|
||||||
PERL5LIB='.' xargs -n1 cpanm --quiet --notest --local-lib $NETDISCO_HOME/perl5
|
PERL5LIB='.' xargs -n1 cpanm --quiet --notest --local-lib "${HOME}/perl5"
|
||||||
|
|
||||||
WORKDIR $NETDISCO_HOME/bin
|
RUN bash -c 'mkdir ${HOME}/{bin,environments,nd-site-local}'
|
||||||
RUN bash -c 'ln -sf $NETDISCO_HOME/perl5/bin/{localenv,netdisco-*} .'
|
RUN bash -c 'ln -sf ${HOME}/perl5/bin/{localenv,netdisco-*} ${HOME}/bin'
|
||||||
ENV PATH $NETDISCO_HOME/bin:$PATH
|
COPY --chown=netdisco:netdisco deployment.yml "${HOME}/environments/"
|
||||||
ENV SHELL "/bin/bash"
|
COPY --chown=netdisco:netdisco wait_to_start.sh "${HOME}/bin/"
|
||||||
|
|
||||||
WORKDIR $NETDISCO_HOME/environments
|
FROM debian:stable-slim
|
||||||
COPY deployment.yml .
|
|
||||||
|
LABEL org.netdisco.maintainer="The Netdisco Project"
|
||||||
|
LABEL org.netdisco.version=${TAG}
|
||||||
|
|
||||||
|
RUN bash -c 'mkdir -p /usr/share/man/man{1..8}' && \
|
||||||
|
apt-get -yq update && \
|
||||||
|
apt-get install -yq --no-install-recommends \
|
||||||
|
ca-certificates \
|
||||||
|
cpanminus \
|
||||||
|
curl \
|
||||||
|
jq \
|
||||||
|
libdbd-pg-perl \
|
||||||
|
libio-socket-ssl-perl \
|
||||||
|
libnet-ldap-perl \
|
||||||
|
libsnmp-perl \
|
||||||
|
libssl-dev \
|
||||||
|
postgresql-client && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=netdisco-build-image \
|
||||||
|
/etc/passwd /etc/group /etc/shadow /etc/
|
||||||
|
|
||||||
|
COPY --from=netdisco-build-image --chown=netdisco:netdisco \
|
||||||
|
/home/netdisco /home/netdisco/
|
||||||
|
|
||||||
VOLUME ["/home/netdisco/environments", "/home/netdisco/nd-site-local"]
|
VOLUME ["/home/netdisco/environments", "/home/netdisco/nd-site-local"]
|
||||||
WORKDIR $NETDISCO_HOME
|
|
||||||
|
USER netdisco:netdisco
|
||||||
|
WORKDIR /home/netdisco
|
||||||
|
ENV PATH "/home/netdisco/bin:$PATH"
|
||||||
|
ENV SHELL /bin/bash
|
||||||
|
|
||||||
CMD ["bash"]
|
CMD ["bash"]
|
||||||
|
|||||||
23
docker/netdisco-base/wait_to_start.sh
Executable file
23
docker/netdisco-base/wait_to_start.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo $WAIT_COMMAND
|
||||||
|
echo $WAIT_START_CMD
|
||||||
|
|
||||||
|
is_ready() {
|
||||||
|
eval "$WAIT_COMMAND"
|
||||||
|
}
|
||||||
|
|
||||||
|
# wait until is ready
|
||||||
|
i=0
|
||||||
|
while ! is_ready; do
|
||||||
|
i=`expr $i + 1`
|
||||||
|
if [ $i -ge $WAIT_LOOPS ]; then
|
||||||
|
echo "$(date) - still not ready, giving up"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "$(date) - waiting to be ready"
|
||||||
|
sleep $WAIT_SLEEP
|
||||||
|
done
|
||||||
|
|
||||||
|
#start the script
|
||||||
|
exec $WAIT_START_CMD
|
||||||
Reference in New Issue
Block a user