Thomas
5 years ago
11 changed files with 247 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||||||
|
online/ |
||||||
|
venv |
||||||
|
Dockerfile |
||||||
|
docker-compose.yml |
||||||
|
.DS_Store |
||||||
|
.git |
||||||
|
.idea |
||||||
|
.vscode |
||||||
|
.gitignore |
||||||
|
.dockerignore |
@ -0,0 +1,14 @@ |
|||||||
|
FROM python:3 |
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED 1 |
||||||
|
|
||||||
|
RUN mkdir /django |
||||||
|
COPY . /django |
||||||
|
WORKDIR /django |
||||||
|
RUN mkdir static_thirdparty \ |
||||||
|
&& wget https://code.jquery.com/jquery-3.4.1.min.js \ |
||||||
|
&& wget https://github.com/twbs/bootstrap/releases/download/v3.4.1/bootstrap-3.4.1-dist.zip \ |
||||||
|
&& unzip bootstrap-3.4.1-dist.zip \ |
||||||
|
&& rm bootstrap-3.4.1-dist.zip |
||||||
|
|
||||||
|
RUN pip install -r requirements.txt |
@ -0,0 +1,18 @@ |
|||||||
|
fp = open("/django/server/settings.py") |
||||||
|
key = "" |
||||||
|
for line in fp: |
||||||
|
if line.startswith("SECRET_KEY"): |
||||||
|
key = line.split(" ")[2] |
||||||
|
break |
||||||
|
fp.close() |
||||||
|
|
||||||
|
with open('/django/config/settings.py', 'r') as file: |
||||||
|
data = file.readlines() |
||||||
|
|
||||||
|
for i, line in enumerate(data): |
||||||
|
if line.startswith("SECRET_KEY"): |
||||||
|
data[i] = "{} = {}".format("SECRET_KEY", key) |
||||||
|
break |
||||||
|
|
||||||
|
with open('/django/config/settings.py', 'w') as file: |
||||||
|
file.writelines(data) |
@ -0,0 +1,9 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
django-admin startproject server . |
||||||
|
python config/copysecret.py |
||||||
|
mv config/* server/ |
||||||
|
rm -rf config |
||||||
|
python manage.py migrate |
||||||
|
echo "from django.contrib.auth.models import User; User.objects.create_superuser('${ADMIN_USER}', '${ADMIN_EMAIL}', '${ADMIN_PW}')" | python manage.py shell |
||||||
|
python manage.py runserver 0.0.0.0:8000 |
@ -0,0 +1,123 @@ |
|||||||
|
""" |
||||||
|
Django settings for djangoserver project. |
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 1.11.20. |
||||||
|
|
||||||
|
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__))) |
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret! |
||||||
|
SECRET_KEY = '&h!kbrmk)la2m%+%-qmdj1&ifg^rj3$o*)sos2dedw$$b4_lp$' |
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production! |
||||||
|
DEBUG = True |
||||||
|
|
||||||
|
ALLOWED_HOSTS = ['*'] |
||||||
|
|
||||||
|
# Application definition |
||||||
|
|
||||||
|
INSTALLED_APPS = [ |
||||||
|
'django.contrib.admin', |
||||||
|
'django.contrib.auth', |
||||||
|
'django.contrib.contenttypes', |
||||||
|
'django.contrib.sessions', |
||||||
|
'django.contrib.messages', |
||||||
|
'django.contrib.staticfiles', |
||||||
|
'cashonly.core', |
||||||
|
'cashonly.web', |
||||||
|
'bootstrapform', |
||||||
|
] |
||||||
|
|
||||||
|
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 = 'server.urls' |
||||||
|
|
||||||
|
TEMPLATES = [ |
||||||
|
{ |
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates', |
||||||
|
'DIRS': [], |
||||||
|
'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', |
||||||
|
], |
||||||
|
}, |
||||||
|
}, |
||||||
|
] |
||||||
|
|
||||||
|
WSGI_APPLICATION = 'server.wsgi.application' |
||||||
|
|
||||||
|
# Database |
||||||
|
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases |
||||||
|
|
||||||
|
DATABASES = { |
||||||
|
'default': { |
||||||
|
'ENGINE': 'django.db.backends.postgresql', |
||||||
|
'NAME': 'postgres', |
||||||
|
'USER': 'postgres', |
||||||
|
'PASSWORD': os.environ.get("POSTGRES_PASSWORD"), |
||||||
|
'HOST': os.environ.get("POSTGRES_HOST"), |
||||||
|
'PORT': 5432, # default |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
# 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', |
||||||
|
}, |
||||||
|
] |
||||||
|
|
||||||
|
LOGIN_URL = '/login/' |
||||||
|
LOGIN_REDIRECT_URL = '/' |
||||||
|
|
||||||
|
# Internationalization |
||||||
|
# https://docs.djangoproject.com/en/1.11/topics/i18n/ |
||||||
|
|
||||||
|
LANGUAGE_CODE = 'de-de' |
||||||
|
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/' |
||||||
|
STATICFILES_DIRS = ['/django/static_thirdparty'] |
||||||
|
|
||||||
|
# Cashonly Stuff |
||||||
|
# https://git.blinkenbunt.org/cashonly/cashonly |
||||||
|
CASHONLY_DAILY_DIGEST_RANGE_HOURS = 24 |
||||||
|
CASHONLY_DEFAULT_DEBIT_LIMIT = 35 |
@ -0,0 +1,27 @@ |
|||||||
|
"""djangoserver URL Configuration |
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see: |
||||||
|
https://docs.djangoproject.com/en/1.11/topics/http/urls/ |
||||||
|
Examples: |
||||||
|
Function views |
||||||
|
1. Add an import: from my_app import views |
||||||
|
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') |
||||||
|
Class-based views |
||||||
|
1. Add an import: from other_app.views import Home |
||||||
|
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') |
||||||
|
Including another URLconf |
||||||
|
1. Import the include() function: from django.conf.urls import url, include |
||||||
|
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) |
||||||
|
""" |
||||||
|
from django.conf.urls import url, include |
||||||
|
from django.contrib import admin |
||||||
|
from django.contrib.auth import views as auth_views |
||||||
|
from django.conf.urls.static import static |
||||||
|
from django.conf import settings |
||||||
|
|
||||||
|
urlpatterns = [ |
||||||
|
url(r'^admin/', admin.site.urls), |
||||||
|
url(r'', include('cashonly.web.urls')), |
||||||
|
url(r'^login/$', auth_views.LoginView.as_view(template_name='cashonly/web/login.html'), name='login'), |
||||||
|
url(r'^logout/$', auth_views.logout_then_login, name='logout_then_login'), |
||||||
|
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |
@ -0,0 +1,16 @@ |
|||||||
|
""" |
||||||
|
WSGI config for server project. |
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``. |
||||||
|
|
||||||
|
For more information on this file, see |
||||||
|
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ |
||||||
|
""" |
||||||
|
|
||||||
|
import os |
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application |
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings") |
||||||
|
|
||||||
|
application = get_wsgi_application() |
@ -0,0 +1,25 @@ |
|||||||
|
version: '3' |
||||||
|
|
||||||
|
services: |
||||||
|
db: |
||||||
|
container_name: cashonly_db |
||||||
|
image: postgres |
||||||
|
restart: always |
||||||
|
environment: |
||||||
|
POSTGRES_PASSWORD: 2z4wMKcVcCio66o6 |
||||||
|
|
||||||
|
web: |
||||||
|
container_name: cashonly_web |
||||||
|
build: . |
||||||
|
restart: always |
||||||
|
command: bash -c "/django/config/init.sh" |
||||||
|
ports: |
||||||
|
- 80:8000 |
||||||
|
depends_on: |
||||||
|
- db |
||||||
|
environment: |
||||||
|
ADMIN_USER: admin |
||||||
|
ADMIN_PW: changeme |
||||||
|
ADMIN_EMAIL: example@admin.me |
||||||
|
POSTGRES_HOST: cashonly_db |
||||||
|
POSTGRES_PASSWORD: 2z4wMKcVcCio66o6 |
Loading…
Reference in new issue