diff --git a/.gitignore b/.gitignore index eef7ab61..49aaa5ee 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ Makefile* Build _build blib -docker/netdisco -!docker/netdisco-*/hooks/* +!docker/hooks/* diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..d7244cb5 --- /dev/null +++ b/docker/Dockerfile @@ -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} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 0386a091..00000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -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 diff --git a/docker/netdisco-backend/hooks/build b/docker/hooks/build similarity index 100% rename from docker/netdisco-backend/hooks/build rename to docker/hooks/build diff --git a/docker/netdisco-base/hooks/post_push b/docker/hooks/post_push similarity index 100% rename from docker/netdisco-base/hooks/post_push rename to docker/hooks/post_push diff --git a/docker/netdisco-backend/Dockerfile b/docker/netdisco-backend/Dockerfile deleted file mode 100644 index 02629f5e..00000000 --- a/docker/netdisco-backend/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker/netdisco-base/Dockerfile b/docker/netdisco-base/Dockerfile deleted file mode 100644 index e5d05b6a..00000000 --- a/docker/netdisco-base/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker/netdisco-base/deployment.yml b/docker/netdisco-base/deployment.yml deleted file mode 100644 index 78dd7dee..00000000 --- a/docker/netdisco-base/deployment.yml +++ /dev/null @@ -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 - diff --git a/docker/netdisco-base/wait_to_start.sh b/docker/netdisco-base/wait_to_start.sh deleted file mode 100755 index 56c4f18a..00000000 --- a/docker/netdisco-base/wait_to_start.sh +++ /dev/null @@ -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 diff --git a/docker/netdisco-do/Dockerfile b/docker/netdisco-do/Dockerfile deleted file mode 100644 index e707019d..00000000 --- a/docker/netdisco-do/Dockerfile +++ /dev/null @@ -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 [""] diff --git a/docker/netdisco-do/hooks/build b/docker/netdisco-do/hooks/build deleted file mode 100755 index 92084c68..00000000 --- a/docker/netdisco-do/hooks/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build --build-arg TAG=$SOURCE_BRANCH -t $IMAGE_NAME . diff --git a/docker/netdisco-postgresql/Dockerfile b/docker/netdisco-postgresql/Dockerfile deleted file mode 100644 index 6bfda6b0..00000000 --- a/docker/netdisco-postgresql/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker/netdisco-postgresql/netdisco-db-entrypoint.sh b/docker/netdisco-postgresql/netdisco-db-entrypoint.sh deleted file mode 100644 index 1266b3e4..00000000 --- a/docker/netdisco-postgresql/netdisco-db-entrypoint.sh +++ /dev/null @@ -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 "$@" diff --git a/docker/netdisco-web/Dockerfile b/docker/netdisco-web/Dockerfile deleted file mode 100644 index 71a0a199..00000000 --- a/docker/netdisco-web/Dockerfile +++ /dev/null @@ -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"] diff --git a/docker/netdisco-web/hooks/build b/docker/netdisco-web/hooks/build deleted file mode 100755 index 92084c68..00000000 --- a/docker/netdisco-web/hooks/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build --build-arg TAG=$SOURCE_BRANCH -t $IMAGE_NAME .