use postgres

This commit is contained in:
clemens 2018-01-11 13:13:53 +01:00
parent 1ca02a9a61
commit 60f04cfa93
7 changed files with 46 additions and 17 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
docker.env
# Created by https://www.gitignore.io/api/pycharm,python,django # Created by https://www.gitignore.io/api/pycharm,python,django
### Django ### ### Django ###

View File

@ -1,9 +1,12 @@
FROM alpine:3.6 FROM alpine:3.6
ADD ["ofu_app/requirements.txt", "/requirements.txt"]
RUN apk upgrade --update && \ RUN apk upgrade --update && \
apk add --update python3 py3-pillow py3-lxml && \ apk add --update python3 py3-pillow py3-lxml py3-psycopg2 && \
pip3 install django==1.11.7 django-jinja django-rest-framework django-analytical requests beautifulsoup4 pip3 install -r /requirements.txt && rm /requirements.txt
ADD ["ofu_app", "/app"]
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
VOLUME ["/data"] VOLUME ["/data"]
CMD ["python3", "manage.py", "runserver", "0.0.0.0:80"] VOLUME ["/app/media"]
ENTRYPOINT ["python3", "manage.py"]
ADD ["ofu_app", "/app"]
CMD ["runserver", "0.0.0.0:80"]

View File

@ -4,10 +4,14 @@ services:
basta_server_web: basta_server_web:
image: docker.wiai.de/basta/server:0.1 image: docker.wiai.de/basta/server:0.1
build: . build: .
ports:
- "8080:80"
volumes: volumes:
- ./data:/data - ./data/data:/data
# basta_server_db: - ./data/media:/media
# image: postgres:alpine env_file:
- docker.env
basta_server_db:
image: postgres:10-alpine
volumes:
- ./data/pgdata/:/var/lib/postgresql/data/
env_file:
- docker.env

View File

@ -12,7 +12,7 @@ from django.db import models
from django.utils import timezone from django.utils import timezone
from django.utils.encoding import smart_text from django.utils.encoding import smart_text
MAX_LENGTH = 60 MAX_LENGTH = 256
# Create your models here. # Create your models here.

View File

@ -19,11 +19,11 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '7tm($-7tz!co8762!)ptmj%)80)qa^z0odee*8-!be!i(a!p4j' SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = bool(os.environ.get('DEBUG', False))
ALLOWED_HOSTS = ['mg-server.ddns.net', 'localhost', '127.0.0.1', 'app.wiai.de'] ALLOWED_HOSTS = os.environ['ALLOWED_HOSTS'].split()
# Application definition # Application definition
@ -96,8 +96,16 @@ WSGI_APPLICATION = 'core.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('POSTGRES_USER', ''),
'USER': os.environ.get('POSTGRES_USER', ''),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD', ''),
'HOST': os.environ.get('DATABASE_HOST', ''),
'PORT': os.environ.get('DATABASE_PORT', ''),
},
'dev': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join('/data', 'db.sqlite3'), 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
} }
} }

View File

@ -1,2 +1,7 @@
django django==1.11.7
djangorestframework django-jinja
django-rest-framework
django-analytical
requests
beautifulsoup4
#psycopg2

7
sample.env Normal file
View File

@ -0,0 +1,7 @@
SECRET_KEY='rjpmgfärjgmgfo4565tr45z'ü+fdig95ld05jger'
ALLOWED_HOSTS=ofu.uni-bamberg.de
DATABASE_HOST=basta_server_db
DATABASE_PORT=5432
DATABASE_NAME=ofu_app
DATABASE_USER=ufu_app
DATABASE_PASSWD=<ultra_secret>