changes for production
This commit is contained in:
parent
fc4a56e369
commit
a1b018d52c
3
Docker/,key
Normal file
3
Docker/,key
Normal file
@ -0,0 +1,3 @@
|
||||
DJANGO_SETTINGS_MODULE=aitrainer_backoffice/aitrainer_backoffice/settings/prod.py
|
||||
MYSQL_ROOT_PASSWORD=andio2009
|
||||
MYSQL_USER=root
|
17
Docker/Dockerfile
Normal file
17
Docker/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM python:3.7
|
||||
WORKDIR /aitrainer_backoffice
|
||||
ADD . /aitrainer_backoffice/
|
||||
RUN apt-get update && apt-get install vim -y
|
||||
RUN pip3 install uwsgi
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
|
||||
COPY uwsgi_params /var/www/aitrainer.info/
|
||||
COPY .key ./
|
||||
ENV DJANGO_KEY=45u49283495j2435294234
|
||||
ENV DJANGO_SETTINGS_MODULE=aitrainer_backoffice/aitrainer_backoffice/settings/prod.py
|
||||
|
||||
|
||||
ENV PORT=8000
|
||||
EXPOSE 8000
|
38
Docker/docker-compose.yml
Normal file
38
Docker/docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
web:
|
||||
build: .
|
||||
container_name: backoffice
|
||||
environment:
|
||||
- DJANGO_KEY
|
||||
volumes:
|
||||
- .:/aitrainer_backoffice
|
||||
- media:/aitrainer_backoffice/aitrainer_backoffice/media
|
||||
depends_on:
|
||||
- mysql-server
|
||||
ports:
|
||||
- "8002:8000"
|
||||
command: gunicorn aitrainer_backoffice.aitrainer_backoffice.wsgi --env DJANGO_SETTINGS_MODULE=aitrainer_backoffice.aitrainer_backoffice.settings.prod --bind 0.0.0.0:8000 --workers 3
|
||||
|
||||
mysql-server:
|
||||
image: mysql:8.0.20
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
|
||||
volumes:
|
||||
- mysql-data-backoffice:/var/lib/mysql
|
||||
ports:
|
||||
- "33060:3306"
|
||||
|
||||
phpmyadmin:
|
||||
image: phpmyadmin/phpmyadmin:latest
|
||||
restart: always
|
||||
environment:
|
||||
PMA_HOST: mysql-server
|
||||
PMA_USER: $MYSQL_USER
|
||||
PMA_PASSWORD: $MYSQL_ROOT_PASSWORD
|
||||
ports:
|
||||
- "8085:80"
|
||||
volumes:
|
||||
mysql-data-backoffice:
|
||||
media:
|
2
Docker/key.env
Normal file
2
Docker/key.env
Normal file
@ -0,0 +1,2 @@
|
||||
DBPASS=268ZQx9usTrvQ18kkMzpM7LwS5g7
|
||||
DBROOT=rUBDFvzlLVdVpST7c9qtFfCULvAb
|
13
Docker/requirements.txt
Normal file
13
Docker/requirements.txt
Normal file
@ -0,0 +1,13 @@
|
||||
django==3.0.8
|
||||
asgiref==3.2.10
|
||||
certifi==2020.6.20
|
||||
chardet==3.0.4
|
||||
idna==2.10
|
||||
pytz==2020.1
|
||||
sqlparse==0.3.1
|
||||
urllib3==1.25.9
|
||||
setuptools==49.2.0
|
||||
mysqlclient==2.0.1
|
||||
requests==2.24.0
|
||||
pillow==7.2.0
|
||||
gunicorn==20.0.4
|
13
Docker/uwsgi_params
Normal file
13
Docker/uwsgi_params
Normal file
@ -0,0 +1,13 @@
|
||||
uwsgi_param QUERY_STRING $query_string;
|
||||
uwsgi_param REQUEST_METHOD $request_method;
|
||||
uwsgi_param CONTENT_TYPE $content_type;
|
||||
uwsgi_param CONTENT_LENGTH $content_length;
|
||||
uwsgi_param REQUEST_URI $request_uri;
|
||||
uwsgi_param PATH_INFO $document_uri;
|
||||
uwsgi_param DOCUMENT_ROOT $document_root;
|
||||
uwsgi_param SERVER_PROTOCOL $server_protocol;
|
||||
uwsgi_param REMOTE_ADDR $remote_addr;
|
||||
uwsgi_param REMOTE_PORT $remote_port;
|
||||
uwsgi_param SERVER_ADDR $server_addr;
|
||||
uwsgi_param SERVER_PORT $server_port;
|
||||
uwsgi_param SERVER_NAME $server_name;
|
@ -89,3 +89,5 @@ class ExerciseTreeAdmin(admin.ModelAdmin):
|
||||
|
||||
admin.site.register(ExerciseType, ExerciseTypeAdmin)
|
||||
admin.site.register(ExerciseTree, ExerciseTreeAdmin)
|
||||
admin.autodiscover()
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BackofficeConfig(AppConfig):
|
||||
name = "aitrainer_backoffice"
|
||||
|
@ -29,7 +29,7 @@ ALLOWED_HOSTS = ['localhost']
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'aitrainer_backoffice.apps.BackofficeConfig',
|
||||
'aitrainer_backoffice',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
|
@ -19,17 +19,17 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.environ['DJANGO_KEY']
|
||||
+SECRET_KEY = '9874959872==9847588jkklnkln$asdf' #os.environ['DJANGO_KEY']
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['localhost', 'andio.eu', 'aitrainer.*']
|
||||
+ALLOWED_HOSTS = ['62.171.188.119', 'localhost', 'andio.eu', 'aitrainer.info','aitrainer.app']
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'aitrainer_backoffice.apps.BackofficeConfig',
|
||||
#'aitrainer_backoffice',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@ -77,8 +77,8 @@ DATABASES = {
|
||||
'NAME': 'aitrainer',
|
||||
'USER': 'aitrainer',
|
||||
'PASSWORD': 'andio2009',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': 3306
|
||||
'HOST': '62.171.188.119',
|
||||
'PORT': 33060
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
@ -129,31 +130,26 @@ LOGGING = {
|
||||
'()': 'django.utils.log.RequireDebugTrue',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'filters': ['require_debug_true'],
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'mylogger': {
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': '/var/log/django_error.log',
|
||||
}
|
||||
},
|
||||
},
|
||||
'level': os.getenv('DJANGO_LOG_LEVEL', 'ERROR'),
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['file'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# deployment settings
|
||||
SECURE_SSL_REDIRECT = False
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
#SECURE_SSL_REDIRECT = False
|
||||
#SESSION_COOKIE_SECURE = True
|
||||
#CSRF_COOKIE_SECURE = True
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
|
@ -18,10 +18,10 @@ Including another URLconf
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from . import views
|
||||
from django.conf import settings #
|
||||
from django.conf.urls.static import static # n
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
|
@ -5,7 +5,7 @@ import sys
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aitrainer_backoffice.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aitrainer_backoffice.settings.dev')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
|
1
aitrainer_backoffice/start_dev.bat
Normal file
1
aitrainer_backoffice/start_dev.bat
Normal file
@ -0,0 +1 @@
|
||||
python manage.py runserver --settings aitrainer_backoffice.settings.dev
|
Loading…
Reference in New Issue
Block a user