Skip to content

Commit

Permalink
docker-rework commit McLive#1
Browse files Browse the repository at this point in the history
  • Loading branch information
aljaxus committed Jul 22, 2019
1 parent 744a0c9 commit df15dd1
Show file tree
Hide file tree
Showing 165 changed files with 283 additions and 6 deletions.
Empty file modified LICENSE
100644 → 100755
Empty file.
6 changes: 2 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ ___

| | |
|:-------------:|:-------------:|
|![Domain list](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010520.png "Domain list")|![Records list](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010707.png "Records list")|
|![Records list filtered](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010719.png "Records list filtered")|![Records list editing](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010732.png "Records list editing")|
|![Records list add](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010743.png "Records list add")|![Records list delete](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010944.png "Records list delete")|
|![API preview](https://share.aljaxus.eu/2019-07-22/12%3A11%3A31am-20190722010913.png "API preview")||
|![Domain list](https://upl0ad.cloud/K738.png "Domain list")|![Records list](https://upl0ad.cloud/EtIL.png "Records list")|
|![API preview](https://upl0ad.cloud/1pVW.png "API preview")||
| | |

___
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3.4"
services:

server:
container_name: powerDNS
restart: unless-stopped
image: powerDNS:latest
build:
context: ./server
dockerfile: dockerfile
command: ["uwsgi"]
volumes:
healthcheck:
test: ["CMD", "curl", "-sSG", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
ports:
- "8080:80"
4 changes: 2 additions & 2 deletions requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Django==1.11.19
Django==1.11.18
django-activeurl==0.1.9
django-appconf==1.0.2
django-bootstrap3==9.0.0
django-bootstrap4==0.0.1
djangorestframework==3.9.1
djangorestframework==3.6.3
ipaddress==1.0.18
virtualenv==1.11.6
mysql-python==1.2.5
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
208 changes: 208 additions & 0 deletions server/DjangoPowerDNS/settings.py.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# --
# DjangoPowerDNS - A PowerDNS web interface
# Copyright (C) 2017 McLive
# --
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# --

"""
Django settings for DjangoPowerDNS project.

Generated by 'django-admin startproject' using Django 1.11.4.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'soome-secret-key--please-change-me-now'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = [
u'i.am.allowed.host'
]

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dpdns.apps.DpdnsConfig',
'django_activeurl',
'bootstrap3',
'bootstrap4',
'dpdns.templatetags.tags',
'rest_framework',
#'rest_framework.authtoken',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'DjangoPowerDNS.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'dpdns.context_processors.enabled_record_types',
],
},
},
]

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
#'rest_framework.authentication.TokenAuthentication',
#'dpdns.api.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
#'dpdns.api_permissions.HasAPIAccess',
)
}

WSGI_APPLICATION = 'DjangoPowerDNS.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'powerdns',
'USER': 'powerdns',
'PASSWORD': 'powerdns-password',
'HOST': 'localhost',
'PORT': '3306',
}
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

STATICFILES_DIRS = (
BASE_DIR + '/static/',
)

MEDIA_ROOT = BASE_DIR + '/media/'
MEDIA_URL = '/media/'

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
LOGIN_URL = '/login/'

# PowerDNS Manager Settings

PDNS_DEFAULT_ZONE_TYPE = 'NATIVE'

PDNS_DEFAULT_RR_TTL = 3600

PDNS_ENABLED_RR_TYPES = [
'A',
'AAAA',
'CNAME',
'SRV',
'SOA',
'NS',
'MX',
'PTR',
'TXT',
'SPF',
'CERT',
'DNSKEY',
'DS',
'KEY',
'NSEC',
'RRSIG',
'HINFO',
'LOC',
'NAPTR',
'RP',
'AFSDB',
'SSHFP',
]

PDNS_DEFAULT_SOA = {
'PRIMARY_NS': "ns1.host.tld",
'EMAIL': "[email protected]"
}

PDNS_EXCLUDE_RECORDS = [
{
'domain': 1,
'regex': r'(vps)\d+' # example exclude vps654564734.yourdomain.tld from being shown in the web interface.
}
]
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions server/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM debian:latest
# Metadata
LABEL maintainer="[email protected]"
# Pre-build
WORKDIR /var/server
RUN apt update -y
RUN apt install -y uwsgi python-mysqldb libmariadbclient-dev
RUN cp ./templates/uwsgi-config.ini /etc/uwsgi/apps-enabled/dpdns.ini
RUN pip install virtualenv
RUN virtualenv venv
RUN source venv/bin/activate
# Build data
COPY ./* ./
RUN pip install -r requirements.txt
RUN python manage.py migrate
RUN python init_createsuperuser.py
# Run on startup
CMD uwsgi
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions server/init_createsuperuser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib.auth.models import User;

username = 'administrator';
password = 'administrator';
email = 'administrator@local';

if User.objects.filter(username=username).count()==0:
User.objects.create_superuser(username, email, password);
print('Superuser created.');
else:
print('Superuser creation skipped.');
0 manage.py → server/manage.py
100644 → 100755
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions server/templates/uwsgi-config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[uwsgi]
base = /var/server/DjangoPowerDNS
chdir = /var/server/

master = true
wsgi-file = %(base)/wsgi.py
touch-reload = %(wsgi-file)
app = wsgi

virtualenv = %(chdir)/venv

socket = 127.0.0.1:7077
plugins-dir = /etc/uwsgi/apps-enabled/
processes = 1
threads = 100
harakiri = 30

logto = /var/log/uwsgi/app/djangopowerdns.log
pidfile2 = /tmp/djangopowerdns.pid

uid = www-data
gid = www-data

0 comments on commit df15dd1

Please sign in to comment.