Delete deprecated all-in-one pdns-admin image

This commit is contained in:
Peter Schiffer 2018-11-07 00:55:44 +01:00
parent a6b9b2ed3a
commit bb15b6cb05
No known key found for this signature in database
GPG key ID: 6CCC5046E2B0B44B
6 changed files with 1 additions and 275 deletions

View file

@ -1,6 +1,6 @@
# PowerDNS Docker Images
This repository contains five Docker images - pdns-mysql, pdns-recursor, pdns-admin-static, pdns-admin-uwsgi and deprecated pdns-admin. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://www.powerdns.com/) with mysql backend (without mysql server). Image **pdns-recursor** contains completely configurable [PowerDNS 4.x recursor](https://www.powerdns.com/). Images **pdns-admin-static** and **pdns-admin-uwsgi** contains fronted (nginx) and backend (uWSGI) for [PowerDNS Admin](https://git.0x97.io/0x97/powerdns-admin) web app, written in Flask, for managing PowerDNS servers. Pdns-admin is also completely configurable. Deprecated **pdns-admin** contains PowerDNS Admin in a single image where both nginx and uWSGI processes are managed by systemd. This image won't be updated anymore.
This repository contains four Docker images - pdns-mysql, pdns-recursor, pdns-admin-static and pdns-admin-uwsgi. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://www.powerdns.com/) with mysql backend (without mysql server). Image **pdns-recursor** contains completely configurable [PowerDNS 4.x recursor](https://www.powerdns.com/). Images **pdns-admin-static** and **pdns-admin-uwsgi** contains fronted (nginx) and backend (uWSGI) for [PowerDNS Admin](https://git.0x97.io/0x97/powerdns-admin) web app, written in Flask, for managing PowerDNS servers. Pdns-admin is also completely configurable.
Most of the images (except *pdns-admin-static* based on `nginx` image) have now also the `alpine` tag thanks to the @PoppyPop .
@ -14,8 +14,6 @@ https://hub.docker.com/r/pschiffe/pdns-admin-uwsgi/
https://hub.docker.com/r/pschiffe/pdns-admin-static/
https://hub.docker.com/r/pschiffe/pdns-admin/
## pdns-mysql
[![](https://images.microbadger.com/badges/version/pschiffe/pdns-mysql.svg)](https://microbadger.com/images/pschiffe/pdns-mysql "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/pschiffe/pdns-mysql.svg)](http://microbadger.com/images/pschiffe/pdns-mysql "Get your own image badge on microbadger.com")
@ -183,74 +181,6 @@ docker run -d -p 8080:80 --name pdns-admin-static \
pschiffe/pdns-admin-static
```
## pdns-admin - DEPRECATED
[![](https://images.microbadger.com/badges/version/pschiffe/pdns-admin.svg)](https://microbadger.com/images/pschiffe/pdns-admin "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/pschiffe/pdns-admin.svg)](http://microbadger.com/images/pschiffe/pdns-admin "Get your own image badge on microbadger.com")
https://hub.docker.com/r/pschiffe/pdns-admin/
Docker image with [PowerDNS Admin](https://github.com/ngoduykhanh/PowerDNS-Admin) web app, written in Flask, for managing PowerDNS servers. The app is running under uWSGI with nginx. Processes in the container are managed by systemd. For running, it needs external mysql server. Env vars for mysql configuration:
```
(name=default value)
PDNS_ADMIN_SQLA_DB_HOST="'mysql'"
PDNS_ADMIN_SQLA_DB_PORT="'3306'"
PDNS_ADMIN_SQLA_DB_USER="'root'"
PDNS_ADMIN_SQLA_DB_PASSWORD="'powerdnsadmin'"
PDNS_ADMIN_SQLA_DB_NAME="'powerdnsadmin'"
```
If linked with official [mariadb](https://hub.docker.com/_/mariadb/) image with alias `mysql`, the connection can be automatically configured, so you don't need to specify any of the above. Also, DB is automatically initialized if tables are missing.
Similar to the pdns-mysql, pdns-admin is also completely configurable via env vars. Prefix in this case is `PDNS_ADMIN_`, but there is one caveat: as the config file is a python source file, every string value must be quoted, as shown above. Double quotes are consumed by Bash, so the single quotes stay for Python. (Port number in this case is treated as string, because later on it's concatenated with hostname, user, etc in the db uri). Configuration from these env vars will be written to the `/opt/powerdns-admin/config.py` file.
### Connecting to the PowerDNS server
For the pdns-admin to make sense, it needs a PowerDNS server to manage. The PowerDNS server needs to have exposed API (example configuration for PowerDNS 4.x):
```
api=yes
api-key=secret
webserver=yes
```
And again, PowerDNS connection is configured via env vars (it needs url of the PowerDNS server, api key and a version of PowerDNS server, for example 4.0.1):
```
(name=default value)
PDNS_ADMIN_PDNS_STATS_URL="'http://pdns:8081/'"
PDNS_ADMIN_PDNS_API_KEY="''"
PDNS_ADMIN_PDNS_VERSION="''"
```
If this container is linked with pdns-mysql from this repo with alias `pdns`, it will be configured automatically and none of the env vars from above are needed to be specified.
### Persistent data
There is a directory with user uploads which should be persistent: `/opt/powerdns-admin/upload`
### Systemd
Because of the systemd is managing processes inside of this container, there are some special requirements when running this container: `/run` and `/tmp` must be mounted on tmpfs, and cgroup filesystem must be bind-mounted from the host. Example Docker run bit when running on Red Hat based distro: `--tmpfs /run --tmpfs /tmp -v /sys/fs/cgroup:/sys/fs/cgroup:ro` (If you are on a recent Fedora, you can install `oci-systemd-hook` rpm package, and you don't need to specify any of this, it will be done automatically for you.)
And if you want to see logs with `docker logs` command, allocate tty for the container with `-t, --tty` option.
### Example
When linked with pdns-mysql from this repo and with LDAP auth:
```
docker run -dt -p 8080:80 --name pdns-admin \
--link mariadb:mysql --link pdns-master:pdns \
-v pdns-admin-upload:/opt/powerdns-admin/upload \
--tmpfs /run --tmpfs /tmp -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-e PDNS_ADMIN_LDAP_TYPE="'ldap'" \
-e PDNS_ADMIN_LDAP_URI="'ldaps://your-ldap-server:636'" \
-e PDNS_ADMIN_LDAP_USERNAME="'cn=dnsuser,ou=users,ou=services,dc=example,dc=com'" \
-e PDNS_ADMIN_LDAP_PASSWORD="'dnsuser'" \
-e PDNS_ADMIN_LDAP_SEARCH_BASE="'ou=System Admins,ou=People,dc=example,dc=com'" \
-e PDNS_ADMIN_LDAP_USERNAMEFIELD="'uid'" \
-e PDNS_ADMIN_LDAP_FILTER="'(objectClass=inetorgperson)'" \
pschiffe/pdns-admin
```
## ansible-playbook.yml
Included ansible playbook can be used to build and run the containers from this repo. Run it simply with:

View file

@ -1,52 +0,0 @@
FROM fedora:26
MAINTAINER "Peter Schiffer" <pschiffe@redhat.com>
RUN dnf -y --setopt=tsflags=nodocs install \
python-pip \
python2-mysql \
python-ldap \
mariadb \
nginx \
uwsgi \
uwsgi-plugin-python \
&& dnf clean all \
&& systemctl enable nginx \
&& systemctl enable uwsgi
RUN mkdir -p /opt/powerdns-admin \
&& curl -sSLk https://git.omicroninteractive.com/0x97/powerdns-admin/repository/archive.tar.gz?ref=master \
| tar -xzC /opt/powerdns-admin --strip 1 \
&& sed -i '/MySQL-python/d' /opt/powerdns-admin/requirements.txt \
&& sed -i '/python-ldap/d' /opt/powerdns-admin/requirements.txt \
&& chown -R root: /opt/powerdns-admin \
&& chown -R uwsgi: /opt/powerdns-admin/upload
WORKDIR /opt/powerdns-admin
RUN pip3 install envtpl \
&& pip install -r requirements.txt \
&& rm -rf ~/.cache/*
STOPSIGNAL SIGRTMIN+3
RUN echo 'ForwardToConsole=yes' >> /etc/systemd/journald.conf
ENV container=docker \
PDNS_ADMIN_LOGIN_TITLE="'PDNS'" \
PDNS_ADMIN_TIMEOUT=10 \
PDNS_ADMIN_LOG_LEVEL="'INFO'" \
PDNS_ADMIN_BASIC_ENABLED=True \
PDNS_ADMIN_SIGNUP_ENABLED=True \
PDNS_ADMIN_RECORDS_ALLOW_EDIT="['SOA', 'NS', 'A', 'AAAA', 'CNAME', 'MX', 'TXT', 'SRV']"
EXPOSE 80
VOLUME [ "/opt/powerdns-admin/upload" ]
COPY pdns-admin.ini /etc/uwsgi.d/
RUN chown uwsgi: /etc/uwsgi.d/pdns-admin.ini
COPY pdns-nginx.conf /etc/nginx/nginx.conf
COPY config.py.tpl /
COPY docker-cmd.sh /init
CMD [ "/init" ]

View file

@ -1,14 +0,0 @@
import os
basedir = os.path.abspath(os.path.dirname(__file__))
{% for key, value in environment('PDNS_ADMIN_') %}{{ key }} = {{ value }}
{% endfor %}
WTF_CSRF_ENABLED = True
BIND_ADDRESS = '0.0.0.0'
PORT = 9393
LOG_FILE = ''
UPLOAD_DIR = '/opt/powerdns-admin/upload'
SQLALCHEMY_DATABASE_URI = 'mysql://' + SQLA_DB_USER + ':' + SQLA_DB_PASSWORD + '@' + SQLA_DB_HOST + ':' + SQLA_DB_PORT + '/' + SQLA_DB_NAME
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = True

View file

@ -1,50 +0,0 @@
#!/bin/bash
set -euo pipefail
# Configure mysql env vars
: "${PDNS_ADMIN_SQLA_DB_HOST:='mysql'}"
: "${PDNS_ADMIN_SQLA_DB_PORT:='3306'}"
: "${PDNS_ADMIN_SQLA_DB_USER:='${MYSQL_ENV_MYSQL_USER:-root}'}"
if [ "${PDNS_ADMIN_SQLA_DB_USER}" = "'root'" ]; then
: "${PDNS_ADMIN_SQLA_DB_PASSWORD:='$MYSQL_ENV_MYSQL_ROOT_PASSWORD'}"
fi
: "${PDNS_ADMIN_SQLA_DB_PASSWORD:='${MYSQL_ENV_MYSQL_PASSWORD:-powerdnsadmin}'}"
: "${PDNS_ADMIN_SQLA_DB_NAME:='${MYSQL_ENV_MYSQL_DATABASE:-powerdnsadmin}'}"
export PDNS_ADMIN_SQLA_DB_HOST PDNS_ADMIN_SQLA_DB_PORT PDNS_ADMIN_SQLA_DB_USER PDNS_ADMIN_SQLA_DB_PASSWORD PDNS_ADMIN_SQLA_DB_NAME
# Configure pdns server env vars
: "${PDNS_ADMIN_PDNS_STATS_URL:='http://pdns:${PDNS_ENV_PDNS_webserver_port:-8081}/'}"
: "${PDNS_ADMIN_PDNS_API_KEY:='${PDNS_ENV_PDNS_api_key:-}'}"
: "${PDNS_ADMIN_PDNS_VERSION:='${PDNS_ENV_VERSION:-}'}"
export PDNS_ADMIN_PDNS_STATS_URL PDNS_ADMIN_PDNS_API_KEY PDNS_ADMIN_PDNS_VERSION
# Generate secret key
[ -f /root/secret-key ] || tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c 32 > /root/secret-key || true
PDNS_ADMIN_SECRET_KEY="'$(cat /root/secret-key)'"
export PDNS_ADMIN_SECRET_KEY
envtpl < /config.py.tpl > /opt/powerdns-admin/config.py
# Initialize DB if needed
MYSQL_COMMAND="mysql -h ${PDNS_ADMIN_SQLA_DB_HOST//\'/} -P ${PDNS_ADMIN_SQLA_DB_PORT//\'/} -u ${PDNS_ADMIN_SQLA_DB_USER//\'/} -p${PDNS_ADMIN_SQLA_DB_PASSWORD//\'/}"
until $MYSQL_COMMAND -e ';' ; do
>&2 echo 'MySQL is unavailable - sleeping'
sleep 1
done
$MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_ADMIN_SQLA_DB_NAME//\'/}"
MYSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${PDNS_ADMIN_SQLA_DB_NAME//\'/}';"
MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE")
if [ "$MYSQL_NUM_TABLE" -eq 0 ]; then
python2 /opt/powerdns-admin/create_db.py
fi
# python2 /opt/powerdns-admin/db_upgrade.py
exec /usr/sbin/init

View file

@ -1,20 +0,0 @@
[uwsgi]
plugins = python
uid=uwsgi
gid=uwsgi
chdir = /opt/powerdns-admin
pythonpath = /opt/powerdns-admin
mount = /=run.py
manage-script-name = true
callable = app
vacuum = true
harakiri = 20
post-buffering = 8192
socket = localhost:9494
pidfile = /run/uwsgi/%n.pid
enable-threads = true

View file

@ -1,68 +0,0 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.fedora.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri @pdns_admin;
}
location @pdns_admin {
include uwsgi_params;
uwsgi_pass localhost:9494;
}
location /static/ {
alias /opt/powerdns-admin/app/static/;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}