move docker builds to netdisco-docker repo and use trigger chain from here

This commit is contained in:
Oliver Gorwits
2018-01-13 22:07:29 +00:00
parent 77c45cfc96
commit b5e564212e
15 changed files with 7 additions and 345 deletions

3
.gitignore vendored
View File

@@ -13,5 +13,4 @@ Makefile*
Build Build
_build _build
blib blib
docker/netdisco !docker/hooks/*
!docker/netdisco-*/hooks/*

6
docker/Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
# vim: ft=Dockerfile
FROM alpine:3.5
ARG TAG
ENV TAG ${TAG:-master}
LABEL org.netdisco.maintainer="The Netdisco Project"
LABEL org.netdisco.version=${TAG}

View File

@@ -1,42 +0,0 @@
version: '3.4'
services:
netdisco-postgresql:
image: netdisco-postgresql:latest
build:
context: netdisco-postgresql
volumes:
- "./netdisco/pgdata:/var/lib/postgresql/data"
netdisco-base:
image: netdisco-base:latest
build:
context: netdisco-base
netdisco-backend:
image: netdisco-backend:latest
build:
context: netdisco-backend
volumes:
- "./netdisco/config:/home/netdisco/environments"
depends_on:
- netdisco-base
links:
- netdisco-postgresql:db
netdisco-web:
image: netdisco-web:latest
build:
context: netdisco-web
volumes:
- "./netdisco/config:/home/netdisco/environments"
depends_on:
- netdisco-base
links:
- netdisco-postgresql:db
netdisco-do:
image: netdisco-do:latest
build:
context: netdisco-do
volumes:
- "./netdisco/config:/home/netdisco/environments"
depends_on:
- netdisco-base
links:
- netdisco-postgresql:db

View File

@@ -1,15 +0,0 @@
# vim: ft=Dockerfile
ARG TAG=master
FROM docker.io/netdisco/netdisco-base:${TAG}-base
LABEL org.netdisco.maintainer="The Netdisco Project"
LABEL org.netdisco.version=${TAG}
WORKDIR /home/netdisco/netdisco-mibs
RUN curl -sL https://api.github.com/repos/netdisco/netdisco-mibs/tags | \
jq '.[]|.tarball_url|select(test("tarball/\\d+\\.\\d+$"))' | \
sort -rg | head -n1 | xargs -n1 curl -sL | tar --strip-components=1 -zxf -
WORKDIR /home/netdisco
ENTRYPOINT ["/home/netdisco/bin/netdisco-backend"]
CMD ["foreground"]

View File

@@ -1,69 +0,0 @@
# vim: ft=Dockerfile
ARG TAG=master
FROM debian:stable-slim as netdisco-build-image
RUN bash -c 'mkdir -p /usr/share/man/man{1..8}' && \
apt-get -yq update && \
apt-get install -yq --no-install-recommends \
build-essential \
ca-certificates \
cpanminus \
curl \
git \
jq \
libdbd-pg-perl \
libio-socket-ssl-perl \
libnet-ldap-perl \
libsnmp-perl \
libssl-dev \
postgresql-client
ENV HOME "/home/netdisco"
RUN groupadd -r netdisco -g 901 && \
useradd -u 901 -r -p x -g netdisco -m -d $HOME -s /bin/bash -c "netdisco user" netdisco
USER netdisco:netdisco
RUN curl -sL https://api.github.com/repos/netdisco/netdisco/tags | \
jq '.[]|.name|select(test("^\\d+\\.\\d+$"))|"https://github.com/netdisco/netdisco.git@"+.' | \
sort -rg | head -n1 | \
PERL5LIB='.' xargs -n1 cpanm --quiet --notest --local-lib "${HOME}/perl5"
RUN bash -c 'mkdir ${HOME}/{bin,environments,nd-site-local}'
RUN bash -c 'ln -sf ${HOME}/perl5/bin/{localenv,netdisco-*} ${HOME}/bin'
COPY deployment.yml "${HOME}/environments/"
COPY wait_to_start.sh "${HOME}/bin/"
FROM debian:stable-slim
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 /home/netdisco /home/netdisco/
RUN chown -R netdisco:netdisco /home/netdisco
VOLUME ["/home/netdisco/environments", "/home/netdisco/nd-site-local"]
USER netdisco:netdisco
WORKDIR /home/netdisco
ENV PATH "/home/netdisco/bin:$PATH"
ENV SHELL /bin/bash
CMD ["bash"]

View File

@@ -1,94 +0,0 @@
#
# NETDISCO 2 CONFIGURATION FILE
#
# Settings in this file override share/config.yml
# See App::Netdisco::Manual::Configuration for more info.
# ------------------
# ESSENTIAL SETTINGS
# ------------------
database:
name: 'netdisco'
user: 'netdisco'
pass: 'netdisco'
#host: 'localhost'
# --------------------
# RECOMMENDED SETTINGS
# --------------------
# SNMP community string(s)
# ````````````````````````
device_auth:
- tag: 'default_v2_readonly'
community: 'public'
read: true
write: false
# - tag: 'default_v2_for_write'
# community: 'private'
# read: false
# write: true
# will be stripped from fqdn when displayed in the web UI
# also, do not forget the leading dot.
# ```````````````````````````````````````````````````````
#domain_suffix: '.example.com'
# ¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸
# ¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸.·´¯`·.¸¸
# ---------------------------------------------------------------
# OTHER INTERESTING SETTINGS WHERE THE DEFAULTS ARE PROBABLY OKAY
# ---------------------------------------------------------------
# do not discover IP Phones or Wireless Access Points.
# usually these are visible as device neighbors but don't support
# SNMP, which just clogs up the job queue.
# ```````````````````````````````````````````````````````````````
#discover_no_type:
# - '(?i)phone'
# - '(?i)(?:wap|wireless)'
# this is the schedule for automatically keeping netdisco up-to-date;
# these are good defaults, so only uncomment if needing to change.
# (or set "schedule: null" if you wish to disable the scheduler)
# ````````````````````````````````````````````````````````````````````
#schedule:
# discoverall:
# when: '5 7 * * *'
# macwalk:
# when:
# min: 20
# arpwalk:
# when:
# min: 50
# nbtwalk:
# when: '0 8,13,21 * * *'
# expire:
# when: '30 23 * * *'
# number of SNMP workers to run in parallel (in netdisco-backend).
# the default is twice the number of CPU cores. increase this if
# your system has few cores and the schedule is taking too long.
# ```````````````````````````````````````````````````````````````
#workers:
# tasks: 'AUTO * 2'
# number of parallel DNS queries for node names
# `````````````````````````````````````````````
#dns:
# max_outstanding: 50
# set to true to globally disable authentication/login.
# create a user called "guest" if you want to assign port/admin rights.
# `````````````````````````````````````````````````````````````````````
no_auth: true
# set to false if you MUST maintain backwards compatibility
# with Netdisco 1.x web frontend.
# `````````````````````````````````````````````````````````
#safe_password_store: true

View File

@@ -1,23 +0,0 @@
#!/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

View File

@@ -1,9 +0,0 @@
# vim: ft=Dockerfile
ARG TAG=master
FROM docker.io/netdisco/netdisco-base:${TAG}-base
LABEL org.netdisco.maintainer="The Netdisco Project"
LABEL org.netdisco.version=${TAG}
ENTRYPOINT ["/home/netdisco/bin/netdisco-do"]
CMD [""]

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker build --build-arg TAG=$SOURCE_BRANCH -t $IMAGE_NAME .

View File

@@ -1,30 +0,0 @@
# vim: ft=Dockerfile
ARG TAG=master
FROM docker.io/postgres:9.6.6-alpine
LABEL org.netdisco.maintainer="The Netdisco Project"
LABEL org.netdisco.version=${TAG}
RUN apk add --no-cache \
curl \
jq \
tar
COPY netdisco-db-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/netdisco-db-entrypoint.sh
RUN PGDATA=/var/lib/postgresql/netdisco-pgdata /usr/local/bin/docker-entrypoint.sh postgres --version
WORKDIR /var/lib/postgresql/netdisco-sql
RUN curl -sL https://api.github.com/repos/netdisco/netdisco/tags | \
jq '.[]|.name|select(test("^\\d+\\.\\d+$"))|"https://api.github.com/repos/netdisco/netdisco/tarball/"+.' | \
sort -rg | head -n1 | xargs -n1 curl -sL | \
tar --wildcards --strip-components=3 -zx '*App-Netdisco-DB-*' && \
curl -sLO "https://raw.githubusercontent.com/netdisco/upstream-sources/master/ieee/oui.sql" && \
curl -sLO "https://raw.githubusercontent.com/netdisco/netdisco/master/lib/App/Netdisco/DB.pm"
VOLUME ["/var/lib/postgresql/data"]
WORKDIR /
ENTRYPOINT ["/usr/local/bin/netdisco-db-entrypoint.sh"]
CMD ["postgres"]

View File

@@ -1,47 +0,0 @@
#!/usr/bin/env bash
su=( su-exec "${PGUSER:-postgres}" )
psql=( psql -X -v ON_ERROR_STOP=0 -v ON_ERROR_ROLLBACK=on )
psql+=( --username netdisco --dbname netdisco )
if [ "$1" = 'postgres' ]; then
if [ ! -s "$PGDATA/PG_VERSION" ]; then
echo >&2 "netdisco-db-entrypoint: copying initial database files"
chmod 700 /var/lib/postgresql/data
chown postgres /var/lib/postgresql/data
cp -a /var/lib/postgresql/netdisco-pgdata/* /var/lib/postgresql/data/
fi
echo >&2 "netdisco-db-entrypoint: starting pg privately to container"
"${su[@]}" pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w start
echo >&2 "netdisco-db-entrypoint: configuring Netdisco db user"
echo "*:*:netdisco:netdisco:netdisco" > ~/.pgpass
chmod 0600 ~/.pgpass
"${su[@]}" createuser -DRSw netdisco
"${su[@]}" createdb -O netdisco netdisco
echo >&2 "netdisco-db-entrypoint: bringing schema up-to-date"
ls -1 /var/lib/postgresql/netdisco-sql/App-Netdisco-DB-* | \
xargs -n1 basename | sort -n -t '-' -k4 | \
while read file; do
"${psql[@]}" -f "/var/lib/postgresql/netdisco-sql/$file"
done
echo >&2 "netdisco-db-entrypoint: importing OUI"
NUMOUI=$("${psql[@]}" -A -t -c "SELECT count(oui) FROM oui")
if [ "$NUMOUI" -eq 0 ]; then
"${psql[@]}" -f /var/lib/postgresql/netdisco-sql/oui.sql
fi
echo >&2 "netdisco-db-entrypoint: marking schema as up-to-date"
MAXSCHEMA=$(grep VERSION /var/lib/postgresql/netdisco-sql/DB.pm | sed 's/[^0-9]//g')
STAMP=$(date '+v%Y%m%d_%H%M%S.000')
"${psql[@]}" -c "CREATE TABLE dbix_class_schema_versions (version varchar(10) PRIMARY KEY, installed varchar(20) NOT NULL)"
"${psql[@]}" -c "INSERT INTO dbix_class_schema_versions VALUES ('${MAXSCHEMA}', '${STAMP}')"
echo >&2 "netdisco-db-entrypoint: shutting down pg (will restart listening for clients)"
"${su[@]}" pg_ctl -D "$PGDATA" -m fast -w stop
fi
exec /usr/local/bin/docker-entrypoint.sh "$@"

View File

@@ -1,10 +0,0 @@
# vim: ft=Dockerfile
ARG TAG=master
FROM docker.io/netdisco/netdisco-base:${TAG}-base
LABEL org.netdisco.maintainer="The Netdisco Project"
LABEL org.netdisco.version=${TAG}
EXPOSE 5000
ENTRYPOINT ["/home/netdisco/bin/netdisco-web"]
CMD ["foreground"]

View File

@@ -1,2 +0,0 @@
#!/bin/bash
docker build --build-arg TAG=$SOURCE_BRANCH -t $IMAGE_NAME .