diff --git a/.envs/.django b/.envs/.django new file mode 100644 index 0000000000000000000000000000000000000000..6bc9faa9458f8f370c2e6c9c42b27c5eabbaeaa9 --- /dev/null +++ b/.envs/.django @@ -0,0 +1,3 @@ +# General +# ------------------------------------------------------------------------------ +DJANGO_SECRET_KEY=NOT_SO_SECRET_DEVKEY diff --git a/.envs/.postgres b/.envs/.postgres new file mode 100644 index 0000000000000000000000000000000000000000..eaf90525551882d47e3dd8d3668c4f5a82e80b8c --- /dev/null +++ b/.envs/.postgres @@ -0,0 +1,8 @@ +# PostgreSQL +# ------------------------------------------------------------------------------ +POSTGRES_HOST=postgres +POSTGRES_PORT=5432 +POSTGRES_DB=rdmo +POSTGRES_USER=rdmo +POSTGRES_PASSWORD=debug + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..088c4d8384fe615531fd7e346c162b192e07b6dd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +image: docker:19.03.0 + +services: + - docker:19.03.0-dind + +variables: + CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA + CONTAINER_DEPLOY_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest + +before_script: + - docker info + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + +stages: + - build + - deploy + +build_develop: + stage: build + script: + - docker build -t $CONTAINER_TEST_IMAGE -f compose/django/Dockerfile.production . + - docker push $CONTAINER_TEST_IMAGE + except: + - master + +deploy_develop: + stage: deploy + script: + - docker pull $CONTAINER_TEST_IMAGE + - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_DEPLOY_IMAGE + - docker push $CONTAINER_DEPLOY_IMAGE + only: + - develop + diff --git a/README.md b/README.md index dc0a71714e09f87d2d1055091460ab26c268f592..2838419984b940dc4af1ea278a044db285426524 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,39 @@ eRA template modifications for the rdmo app - https://github.com/rdmorganiser/rdmo-app -# Usage + +# Docker + +list running containers + + docker ps + +enter running container + + docker exec -it plan-git_django_1 bash + +logs + + docker logs rdmo_django_1 + +## compose + +build images: + + docker-compose build + +run container: + + docker-compose build + +create super-user (on first run) + + docker exec -it plan-git_django_1 python3 manage.py createsuperuser + + + + +# Usage (without docker - old) Clone the repo next to the rdmo-app dir and add symbolic links diff --git a/compose/django/Dockerfile b/compose/django/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d08fa8026891d155c18248d6b61e4d057b859f20 --- /dev/null +++ b/compose/django/Dockerfile @@ -0,0 +1,39 @@ +# FROM debian:buster +FROM debian:buster-slim + +RUN apt update -y && apt upgrade -y && apt install -y \ + python3 \ + python3-dev \ + python3-pip \ + git + + +# postgres +RUN apt install -y \ + libpq-dev \ + postgresql-client \ + python3-psycopg2 + + +RUN git clone https://github.com/rdmorganiser/rdmo-app.git /app + +WORKDIR /app + +RUN pip3 install rdmo + +#COPY ./theme /app/theme +COPY ./locale /app/locale + +COPY ./config/local.py /app/config/settings/local.py + +COPY ./compose/django/entrypoint /entrypoint +RUN chmod +x /entrypoint + +COPY ./compose/django/start /start +RUN chmod +x /start + +ENV DJANGO_SECRET_KEY=NOT_SO_SECRET_TEMP_KEY +RUN python3 manage.py download_vendor_files + +ENTRYPOINT ["/entrypoint"] + diff --git a/compose/django/Dockerfile.0.11.0 b/compose/django/Dockerfile.0.11.0 new file mode 100644 index 0000000000000000000000000000000000000000..a623a559374b50b2b0e1be548746399edf0bc9ed --- /dev/null +++ b/compose/django/Dockerfile.0.11.0 @@ -0,0 +1,43 @@ +FROM debian:buster +# FROM debian:buster-slim ? + +RUN apt update -y && apt upgrade -y && apt install -y \ + python3 \ + python3-dev \ + python3-pip + +# build-deps +RUN apt install -y \ + git + +# postgres +#RUN apt install -y \ +# libpq-dev \ +# postgresql \ +# postgresql-client \ +# python-psycopg2 + + +RUN git clone https://github.com/rdmorganiser/rdmo-app.git /app + +WORKDIR /app + +# create docker image for 0.11.0 first +RUN git checkout 89749332435a00d096afc2a16704c09f6f3525c7 +#RUN pip3 install --upgrade pip setuptools +RUN pip3 install 'rdmo==0.11.0' + +COPY ./theme /app/theme +COPY ./locale /app/locale + +COPY ./config/local.py /app/config/settings/local.py + +RUN ls + +RUN python3 manage.py migrate # initializes the database +RUN python3 manage.py setup_groups # creates groups with different permissions +RUN python3 manage.py createsuperuser # creates the admin user + +RUN python3 manage.py download_vendor_files + + diff --git a/compose/django/Dockerfile.production b/compose/django/Dockerfile.production new file mode 100644 index 0000000000000000000000000000000000000000..91c38a43370b073d726d9c450c597515e97c9fdf --- /dev/null +++ b/compose/django/Dockerfile.production @@ -0,0 +1,53 @@ +FROM debian:buster-slim + +ENV PYTHONUNBUFFERED 1 + +# install required +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 \ + python3-pkg-resources \ + python3-psycopg2 \ + && rm -rf /var/lib/apt/lists/* + +# download rdmo-app rom github +RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \ + && mkdir /app \ + && curl -SL https://github.com/rdmorganiser/rdmo-app/archive/master.tar.gz \ + | tar --strip-components=1 -xzC /app \ + && apt-get remove -y curl ca-certificates\ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# install rdmo and gunicorn +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-pip python3-dev python3-setuptools gcc python3-wheel \ + && pip3 install rdmo \ + && pip3 install gunicorn \ + && apt-get remove -y python3-pip python3-dev python3-setuptools gcc python3-wheel \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +#COPY ./theme /app/theme +COPY ./locale /app/locale + +COPY ./config/production.py /app/config/settings/local.py + +# download vendor files +ENV DJANGO_SECRET_KEY=NOT_SO_SECRET_TEMP_KEY +RUN python3 manage.py download_vendor_files + +RUN addgroup --system --gid 200 django \ + && adduser --system --uid 200 --ingroup django django \ + && chown -R django /app + +COPY ./compose/django/entrypoint /entrypoint +COPY ./compose/django/start.production /start + +RUN chmod +x /entrypoint /start \ + && chown django /entrypoint /start + +USER django +ENTRYPOINT ["/entrypoint"] + diff --git a/compose/django/entrypoint b/compose/django/entrypoint new file mode 100644 index 0000000000000000000000000000000000000000..ba5831b7f3878f688d18220ad5f9f20ed2a476eb --- /dev/null +++ b/compose/django/entrypoint @@ -0,0 +1,41 @@ +#!/bin/bash + +set -o errexit +set -o pipefail +set -o nounset + +if [ -z "${POSTGRES_USER}" ]; then + base_postgres_image_default_user='postgres' + export POSTGRES_USER="${base_postgres_image_default_user}" +fi + +postgres_ready() { +python3 << END +import sys + +import psycopg2 + +try: + psycopg2.connect( + dbname="${POSTGRES_DB}", + user="${POSTGRES_USER}", + password="${POSTGRES_PASSWORD}", + host="${POSTGRES_HOST}", + port="${POSTGRES_PORT}", + ) +except psycopg2.OperationalError: + sys.exit(-1) +sys.exit(0) + +END +} + +until postgres_ready; do + >&2 echo 'Waiting for PostgreSQL to become available...' + sleep 1 +done +>&2 echo 'PostgreSQL is available' + + +exec "$@" + diff --git a/compose/django/start b/compose/django/start new file mode 100644 index 0000000000000000000000000000000000000000..d7c985b82c40425981f776f3099f936be44fb82b --- /dev/null +++ b/compose/django/start @@ -0,0 +1,15 @@ +#!/bin/bash + +set -o errexit +set -o pipefail +set -o nounset + +# todo: +# https://rdmo.readthedocs.io/en/latest/installation/setup.html +# - do this commands need to run every time? +# - should setup_groups only run once per db setup? +# - would this also handle rdmo upgrades on the db? -> https://rdmo.readthedocs.io/en/latest/upgrade/index.html +python3 manage.py migrate # initializes the database +python3 manage.py setup_groups # creates groups with different permissions + +python3 manage.py runserver 0.0.0.0:8000 diff --git a/compose/django/start.production b/compose/django/start.production new file mode 100644 index 0000000000000000000000000000000000000000..554f4e620244ae5b57dbc334404ae035a20f8543 --- /dev/null +++ b/compose/django/start.production @@ -0,0 +1,8 @@ +#!/bin/bash + +set -o errexit +set -o pipefail +set -o nounset + +python3 /app/manage.py collectstatic --noinput +/usr/local/bin/gunicorn config.wsgi --bind 0.0.0.0:5000 --chdir=/app diff --git a/compose/postgres/Dockerfile b/compose/postgres/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..267e0c8ccb2b33069110cc323a190ae69e0d8e14 --- /dev/null +++ b/compose/postgres/Dockerfile @@ -0,0 +1,7 @@ +FROM postgres:11.3 + +#COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance +#RUN chmod +x /usr/local/bin/maintenance/* +#RUN mv /usr/local/bin/maintenance/* /usr/local/bin \ +# && rmdir /usr/local/bin/maintenance + diff --git a/config/local.py b/config/local.py new file mode 100644 index 0000000000000000000000000000000000000000..41525af7c89398808bc2e31e8edf57cc0b1d4f23 --- /dev/null +++ b/config/local.py @@ -0,0 +1,263 @@ +import os +from . import BASE_DIR + +''' +Debug mode, don't use this in production +''' + +DEBUG = True + + +''' +A secret key for a particular Django installation. This is used to provide +cryptographic signing, and should be set to a unique, unpredictable value. +''' + +SECRET_KEY = os.getenv('DJANGO_SECRET_KEY') + +''' +The list of URLs und which this application available +''' + +ALLOWED_HOSTS = ['localhost', 'ip6-localhost', '127.0.0.1', '[::1]'] + +''' +The root url of your application, only needed when its not '/' +''' + +# BASE_URL = '/path' + +''' +Language code and time zone +''' +LANGUAGE_CODE = 'de-de' +TIME_ZONE = 'Europe/Berlin' + +''' +The database connection to be used, see also: +http://rdmo.readthedocs.io/en/latest/configuration/databases.html +''' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': os.getenv('POSTGRES_DB'), + 'USER': os.getenv('POSTGRES_USER'), + 'PASSWORD': os.getenv('POSTGRES_PASSWORD'), + 'HOST': os.getenv('POSTGRES_HOST'), + 'PORT': os.getenv('POSTGRES_PORT'), + } +} + +''' +E-Mail configuration, see also: +http://rdmo.readthedocs.io/en/latest/configuration/email.html +''' + +# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +# EMAIL_HOST = 'localhost' +# EMAIL_PORT = '25' +# EMAIL_HOST_USER = '' +# EMAIL_HOST_PASSWORD = '' +# EMAIL_USE_TLS = False +# EMAIL_USE_SSL = False +# DEFAULT_FROM_EMAIL = '' + +''' +Allauth configuration, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/allauth.html +''' + +# from rdmo.core.settings import INSTALLED_APPS, AUTHENTICATION_BACKENDS +# +# ACCOUNT = True +# ACCOUNT_SIGNUP = True +# SOCIALACCOUNT = False +# +# INSTALLED_APPS += [ +# 'allauth', +# 'allauth.account', +# 'allauth.socialaccount', +# 'allauth.socialaccount.providers.facebook', +# 'allauth.socialaccount.providers.github', +# 'allauth.socialaccount.providers.google', +# 'allauth.socialaccount.providers.orcid', +# 'allauth.socialaccount.providers.twitter', +# ] +# +# AUTHENTICATION_BACKENDS.append('allauth.account.auth_backends.AuthenticationBackend') + +''' +LDAP, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/ldap.html +''' + +# import ldap +# from django_auth_ldap.config import LDAPSearch +# from rdmo.core.settings import AUTHENTICATION_BACKENDS +# +# PROFILE_UPDATE = False +# +# AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com" +# AUTH_LDAP_BIND_DN = "cn=admin,dc=ldap,dc=example,dc=com" +# AUTH_LDAP_BIND_PASSWORD = "admin" +# AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=ldap,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)") +# +# AUTH_LDAP_USER_ATTR_MAP = { +# "first_name": "givenName", +# "last_name": "sn", +# 'email': 'mail' +# } +# +# AUTHENTICATION_BACKENDS.insert( +# AUTHENTICATION_BACKENDS.index('django.contrib.auth.backends.ModelBackend'), +# 'django_auth_ldap.backend.LDAPBackend' +# ) + +''' +Shibboleth, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/shibboleth.html +''' + +# from rdmo.core.settings import INSTALLED_APPS, AUTHENTICATION_BACKENDS, MIDDLEWARE_CLASSES +# +# SHIBBOLETH = True +# PROFILE_UPDATE = False +# +# INSTALLED_APPS += ['shibboleth'] +# +# SHIBBOLETH_ATTRIBUTE_MAP = { +# 'uid': (True, 'username'), +# 'givenName': (True, 'first_name'), +# 'sn': (True, 'last_name'), +# 'mail': (True, 'email'), +# } +# +# AUTHENTICATION_BACKENDS.append('shibboleth.backends.ShibbolethRemoteUserBackend') +# +# MIDDLEWARE_CLASSES.insert( +# MIDDLEWARE_CLASSES.index('django.contrib.auth.middleware.AuthenticationMiddleware') + 1, +# 'shibboleth.middleware.ShibbolethRemoteUserMiddleware' +# ) +# +# LOGIN_URL = '/Shibboleth.sso/Login?target=/projects' +# LOGOUT_URL = '/Shibboleth.sso/Logout' + +''' +Theme, see also: +http://rdmo.readthedocs.io/en/latest/configuration/themes.html +''' + +# THEME_DIR = os.path.join(BASE_DIR, 'theme') + +''' +Export Formats +''' + +# from django.utils.translation import ugettext_lazy as _ +# EXPORT_FORMATS = ( +# ('pdf', _('PDF')), +# ('rtf', _('Rich Text Format')), +# ('odt', _('Open Office')), +# ('docx', _('Microsoft Office')), +# ('html', _('HTML')), +# ('markdown', _('Markdown')), +# ('mediawiki', _('mediawiki')), +# ('tex', _('LaTeX')) +# ) + +''' +Cache, see also: +http://rdmo.readthedocs.io/en/latest/configuration/cache.html +''' + +# CACHES = { +# 'default': { +# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', +# 'LOCATION': '127.0.0.1:11211', +# 'KEY_PREFIX': 'rdmo_default' +# }, +# 'api': { +# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', +# 'LOCATION': '127.0.0.1:11211', +# 'KEY_PREFIX': 'rdmo_api' +# }, +# } + +''' +Logging configuration +''' + +# import os +# from . import BASE_DIR + +# LOGGING_DIR = os.path.join(BASE_DIR, 'log') +# LOGGING = { +# 'version': 1, +# 'disable_existing_loggers': True, +# 'filters': { +# 'require_debug_false': { +# '()': 'django.utils.log.RequireDebugFalse' +# }, +# 'require_debug_true': { +# '()': 'django.utils.log.RequireDebugTrue' +# } +# }, +# 'formatters': { +# 'default': { +# 'format': '[%(asctime)s] %(levelname)s: %(message)s' +# }, +# 'name': { +# 'format': '[%(asctime)s] %(levelname)s %(name)s: %(message)s' +# }, +# 'console': { +# 'format': '[%(asctime)s] %(message)s' +# } +# }, +# 'handlers': { +# 'mail_admins': { +# 'level': 'ERROR', +# 'filters': ['require_debug_false'], +# 'class': 'django.utils.log.AdminEmailHandler' +# }, +# 'error_log': { +# 'level': 'ERROR', +# 'class':'logging.FileHandler', +# 'filename': os.path.join(LOGGING_DIR, 'error.log'), +# 'formatter': 'default' +# }, +# 'rdmo_log': { +# 'level': 'DEBUG', +# 'class':'logging.FileHandler', +# 'filename': os.path.join(LOGGING_DIR, 'rdmo.log'), +# 'formatter': 'name' +# }, +# 'console': { +# 'level': 'DEBUG', +# 'filters': ['require_debug_true'], +# 'class': 'logging.StreamHandler', +# 'formatter': 'console' +# } +# }, +# 'loggers': { +# 'django': { +# 'handlers': ['console'], +# 'level': 'INFO', +# }, +# 'django.request': { +# 'handlers': ['mail_admins', 'error_log'], +# 'level': 'ERROR', +# 'propagate': True +# }, +# 'rdmo': { +# 'handlers': ['rdmo_log'], +# 'level': 'DEBUG', +# 'propagate': False +# } +# } +# } + +VENDOR_CDN = False + +THEME_DIR = os.path.join(BASE_DIR, 'theme') + diff --git a/config/production.py b/config/production.py new file mode 100644 index 0000000000000000000000000000000000000000..df0eaa17ce3568f37860a0c95312d339a48e52ee --- /dev/null +++ b/config/production.py @@ -0,0 +1,262 @@ +import os +from . import BASE_DIR + +''' +Debug mode, don't use this in production +''' + +DEBUG = False + +''' +A secret key for a particular Django installation. This is used to provide +cryptographic signing, and should be set to a unique, unpredictable value. +''' + +SECRET_KEY = os.getenv('DJANGO_SECRET_KEY') + +''' +The list of URLs und which this application available +''' + +ALLOWED_HOSTS = ['localhost', 'ip6-localhost', '127.0.0.1', '[::1]'] + +''' +The root url of your application, only needed when its not '/' +''' + +# BASE_URL = '/path' + +''' +Language code and time zone +''' +LANGUAGE_CODE = 'de-de' +TIME_ZONE = 'Europe/Berlin' + +''' +The database connection to be used, see also: +http://rdmo.readthedocs.io/en/latest/configuration/databases.html +''' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': os.getenv('POSTGRES_DB'), + 'USER': os.getenv('POSTGRES_USER'), + 'PASSWORD': os.getenv('POSTGRES_PASSWORD'), + 'HOST': os.getenv('POSTGRES_HOST'), + 'PORT': os.getenv('POSTGRES_PORT'), + } +} + +''' +E-Mail configuration, see also: +http://rdmo.readthedocs.io/en/latest/configuration/email.html +''' + +# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +# EMAIL_HOST = 'localhost' +# EMAIL_PORT = '25' +# EMAIL_HOST_USER = '' +# EMAIL_HOST_PASSWORD = '' +# EMAIL_USE_TLS = False +# EMAIL_USE_SSL = False +# DEFAULT_FROM_EMAIL = '' + +''' +Allauth configuration, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/allauth.html +''' + +# from rdmo.core.settings import INSTALLED_APPS, AUTHENTICATION_BACKENDS +# +# ACCOUNT = True +# ACCOUNT_SIGNUP = True +# SOCIALACCOUNT = False +# +# INSTALLED_APPS += [ +# 'allauth', +# 'allauth.account', +# 'allauth.socialaccount', +# 'allauth.socialaccount.providers.facebook', +# 'allauth.socialaccount.providers.github', +# 'allauth.socialaccount.providers.google', +# 'allauth.socialaccount.providers.orcid', +# 'allauth.socialaccount.providers.twitter', +# ] +# +# AUTHENTICATION_BACKENDS.append('allauth.account.auth_backends.AuthenticationBackend') + +''' +LDAP, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/ldap.html +''' + +# import ldap +# from django_auth_ldap.config import LDAPSearch +# from rdmo.core.settings import AUTHENTICATION_BACKENDS +# +# PROFILE_UPDATE = False +# +# AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com" +# AUTH_LDAP_BIND_DN = "cn=admin,dc=ldap,dc=example,dc=com" +# AUTH_LDAP_BIND_PASSWORD = "admin" +# AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=ldap,dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)") +# +# AUTH_LDAP_USER_ATTR_MAP = { +# "first_name": "givenName", +# "last_name": "sn", +# 'email': 'mail' +# } +# +# AUTHENTICATION_BACKENDS.insert( +# AUTHENTICATION_BACKENDS.index('django.contrib.auth.backends.ModelBackend'), +# 'django_auth_ldap.backend.LDAPBackend' +# ) + +''' +Shibboleth, see also: +http://rdmo.readthedocs.io/en/latest/configuration/authentication/shibboleth.html +''' + +# from rdmo.core.settings import INSTALLED_APPS, AUTHENTICATION_BACKENDS, MIDDLEWARE_CLASSES +# +# SHIBBOLETH = True +# PROFILE_UPDATE = False +# +# INSTALLED_APPS += ['shibboleth'] +# +# SHIBBOLETH_ATTRIBUTE_MAP = { +# 'uid': (True, 'username'), +# 'givenName': (True, 'first_name'), +# 'sn': (True, 'last_name'), +# 'mail': (True, 'email'), +# } +# +# AUTHENTICATION_BACKENDS.append('shibboleth.backends.ShibbolethRemoteUserBackend') +# +# MIDDLEWARE_CLASSES.insert( +# MIDDLEWARE_CLASSES.index('django.contrib.auth.middleware.AuthenticationMiddleware') + 1, +# 'shibboleth.middleware.ShibbolethRemoteUserMiddleware' +# ) +# +# LOGIN_URL = '/Shibboleth.sso/Login?target=/projects' +# LOGOUT_URL = '/Shibboleth.sso/Logout' + +''' +Theme, see also: +http://rdmo.readthedocs.io/en/latest/configuration/themes.html +''' + +# THEME_DIR = os.path.join(BASE_DIR, 'theme') + +''' +Export Formats +''' + +# from django.utils.translation import ugettext_lazy as _ +# EXPORT_FORMATS = ( +# ('pdf', _('PDF')), +# ('rtf', _('Rich Text Format')), +# ('odt', _('Open Office')), +# ('docx', _('Microsoft Office')), +# ('html', _('HTML')), +# ('markdown', _('Markdown')), +# ('mediawiki', _('mediawiki')), +# ('tex', _('LaTeX')) +# ) + +''' +Cache, see also: +http://rdmo.readthedocs.io/en/latest/configuration/cache.html +''' + +# CACHES = { +# 'default': { +# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', +# 'LOCATION': '127.0.0.1:11211', +# 'KEY_PREFIX': 'rdmo_default' +# }, +# 'api': { +# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', +# 'LOCATION': '127.0.0.1:11211', +# 'KEY_PREFIX': 'rdmo_api' +# }, +# } + +''' +Logging configuration +''' + +# import os +# from . import BASE_DIR + +# LOGGING_DIR = os.path.join(BASE_DIR, 'log') +# LOGGING = { +# 'version': 1, +# 'disable_existing_loggers': True, +# 'filters': { +# 'require_debug_false': { +# '()': 'django.utils.log.RequireDebugFalse' +# }, +# 'require_debug_true': { +# '()': 'django.utils.log.RequireDebugTrue' +# } +# }, +# 'formatters': { +# 'default': { +# 'format': '[%(asctime)s] %(levelname)s: %(message)s' +# }, +# 'name': { +# 'format': '[%(asctime)s] %(levelname)s %(name)s: %(message)s' +# }, +# 'console': { +# 'format': '[%(asctime)s] %(message)s' +# } +# }, +# 'handlers': { +# 'mail_admins': { +# 'level': 'ERROR', +# 'filters': ['require_debug_false'], +# 'class': 'django.utils.log.AdminEmailHandler' +# }, +# 'error_log': { +# 'level': 'ERROR', +# 'class':'logging.FileHandler', +# 'filename': os.path.join(LOGGING_DIR, 'error.log'), +# 'formatter': 'default' +# }, +# 'rdmo_log': { +# 'level': 'DEBUG', +# 'class':'logging.FileHandler', +# 'filename': os.path.join(LOGGING_DIR, 'rdmo.log'), +# 'formatter': 'name' +# }, +# 'console': { +# 'level': 'DEBUG', +# 'filters': ['require_debug_true'], +# 'class': 'logging.StreamHandler', +# 'formatter': 'console' +# } +# }, +# 'loggers': { +# 'django': { +# 'handlers': ['console'], +# 'level': 'INFO', +# }, +# 'django.request': { +# 'handlers': ['mail_admins', 'error_log'], +# 'level': 'ERROR', +# 'propagate': True +# }, +# 'rdmo': { +# 'handlers': ['rdmo_log'], +# 'level': 'DEBUG', +# 'propagate': False +# } +# } +# } + +VENDOR_CDN = False + +#THEME_DIR = os.path.join(BASE_DIR, 'theme') + diff --git a/docker-compose.prod.yaml b/docker-compose.prod.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3945bfa81b3bcbb644a0d62131a89ef0d0c3b5cb --- /dev/null +++ b/docker-compose.prod.yaml @@ -0,0 +1,35 @@ +--- +version: '3' + +volumes: + local_postgres_data: {} + local_postgres_data_backups: {} + +services: + django: + build: + context: . + dockerfile: ./compose/django/Dockerfile.production + image: rdmo_local_django + depends_on: + - postgres + volumes: + - /var/www/html/static:/app/static_root + env_file: + - ./.envs/.django + - ./.envs/.postgres + ports: + - "5000:5000" + command: /start + + postgres: + build: + context: . + dockerfile: ./compose/postgres/Dockerfile + image: rdmo_production_postgres + volumes: + - local_postgres_data:/var/lib/postgresql/data + - local_postgres_data_backups:/backups + env_file: + - ./.envs/.postgres + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..51fe6fd61adcb433244471744d48eff7f51b06d6 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,35 @@ +--- +version: '3' + +volumes: + local_postgres_data: {} + local_postgres_data_backups: {} + +services: + django: + build: + context: . + dockerfile: ./compose/django/Dockerfile + image: rdmo_local_django + depends_on: + - postgres + volumes: + - ./theme:/app/theme + env_file: + - ./.envs/.django + - ./.envs/.postgres + ports: + - "8000:8000" + command: /start + + postgres: + build: + context: . + dockerfile: ./compose/postgres/Dockerfile + image: rdmo_production_postgres + volumes: + - local_postgres_data:/var/lib/postgresql/data + - local_postgres_data_backups:/backups + env_file: + - ./.envs/.postgres +