import docker data to netdisco repo
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
# vim: ft=Dockerfile
|
|
||||||
FROM docker.io/alpine:3.7
|
|
||||||
|
|
||||||
ARG TAG
|
|
||||||
ENV TAG ${TAG:-2.000000}
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
curl
|
|
||||||
|
|
||||||
RUN curl -u "$GHTOKID:$GHTOKVAL" \
|
|
||||||
--data '{"tag_name": "$TAG", "target_commitish": "og-import-irasnyd"}' \
|
|
||||||
"https://api.github.com/repos/netdisco/netdisco-docker/releases"
|
|
||||||
|
|
||||||
CMD ["sh"]
|
|
||||||
24
docker/docker-compose.yml
Normal file
24
docker/docker-compose.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
version: '3.4'
|
||||||
|
services:
|
||||||
|
netdisco-postgresql:
|
||||||
|
image: netdisco-postgresql:latest
|
||||||
|
build:
|
||||||
|
context: netdisco-postgresql
|
||||||
|
args:
|
||||||
|
- TAG
|
||||||
|
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
|
||||||
9
docker/netdisco-backend/Dockerfile
Normal file
9
docker/netdisco-backend/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# vim: ft=Dockerfile
|
||||||
|
FROM netdisco-base:latest
|
||||||
|
|
||||||
|
RUN mkdir $NETDISCO_HOME/netdisco-mibs && cd $NETDISCO_HOME/netdisco-mibs && \
|
||||||
|
curl -s https://api.github.com/repos/netdisco/netdisco-mibs/tags | \
|
||||||
|
jq '.[]|.tarball_url|select(test("tarball/\\d+\\.\\d+$"))' | \
|
||||||
|
sort -rg | head -n1 | xargs -n1 curl -L | tar --strip-components=1 -zxf -
|
||||||
|
|
||||||
|
CMD bash
|
||||||
39
docker/netdisco-base/Dockerfile
Normal file
39
docker/netdisco-base/Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# vim: ft=Dockerfile
|
||||||
|
FROM debian:stable-slim
|
||||||
|
|
||||||
|
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 \
|
||||||
|
daemontools-run \
|
||||||
|
git \
|
||||||
|
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/*
|
||||||
|
|
||||||
|
ENV NETDISCO_HOME "/home/netdisco"
|
||||||
|
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
|
||||||
|
USER netdisco:netdisco
|
||||||
|
|
||||||
|
RUN curl -s 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 $NETDISCO_HOME/perl5
|
||||||
|
|
||||||
|
RUN mkdir $NETDISCO_HOME/bin && \
|
||||||
|
bash -c 'ln -sf $NETDISCO_HOME/perl5/bin/{localenv,netdisco-*} $NETDISCO_HOME/bin/'
|
||||||
|
ENV PATH $NETDISCO_HOME/bin:$PATH
|
||||||
|
ENV SHELL "/bin/bash"
|
||||||
|
|
||||||
|
WORKDIR $NETDISCO_HOME
|
||||||
|
CMD bash
|
||||||
29
docker/netdisco-postgresql/Dockerfile
Normal file
29
docker/netdisco-postgresql/Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# vim: ft=Dockerfile
|
||||||
|
FROM docker.io/postgres:9.6.6-alpine
|
||||||
|
|
||||||
|
ARG TAG
|
||||||
|
ENV TAG ${TAG:-master}
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
curl \
|
||||||
|
jq \
|
||||||
|
tar
|
||||||
|
|
||||||
|
WORKDIR /var/lib/postgresql/netdisco-sql
|
||||||
|
RUN curl -sL "https://api.github.com/repos/netdisco/netdisco/tarball/${TAG}" | \
|
||||||
|
tar --wildcards -zt '*App-Netdisco-DB-*' | xargs -n1 basename | sort -n -t '-' -k4 | \
|
||||||
|
while read file; \
|
||||||
|
do curl -sLO "https://raw.githubusercontent.com/netdisco/netdisco/${TAG}/share/schema_versions/$file"; \
|
||||||
|
done && \
|
||||||
|
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"
|
||||||
|
|
||||||
|
RUN PGDATA=/var/lib/postgresql/netdisco-pgdata /usr/local/bin/docker-entrypoint.sh postgres --version
|
||||||
|
|
||||||
|
COPY netdisco-db-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/netdisco-db-entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
VOLUME /var/lib/postgresql/data
|
||||||
|
ENTRYPOINT ["/usr/local/bin/netdisco-db-entrypoint.sh"]
|
||||||
|
CMD ["postgres"]
|
||||||
47
docker/netdisco-postgresql/netdisco-db-entrypoint.sh
Normal file
47
docker/netdisco-postgresql/netdisco-db-entrypoint.sh
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/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 "$@"
|
||||||
Reference in New Issue
Block a user