diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a5e3e73 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +env +compose +public +node_modules +bower_components +tmp_emails +tmp +var diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b36fd13 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,58 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# Howto with your editor: http://editorconfig.org/#download +# Sublime: https://github.com/sindresorhus/editorconfig-sublime + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[**] +end_of_line = lf +insert_final_newline = true + +# Standard at: https://github.com/felixge/node-style-guide +[**.{js,json}] +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 +quote_type = single +curly_bracket_next_line = false +spaces_around_operators = true +space_after_control_statements = true +space_after_anonymous_functions = true +spaces_in_brackets = false + +# No Standard. Please document a standard if different from .js +[**.{yml,css}] +trim_trailing_whitespace = true +indent_style = tab + +[**.html] +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +# No standard. Please document a standard if different from .js +[**.md] +indent_style = tab + +[**.py] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +# Standard at: +[Makefile] +indent_style = tab + +[**.yml] +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +# The indentation in package.json will always need to be 2 spaces +# https://github.com/npm/npm/issues/4718 +[{package, bower}.json] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore index 093c5a1..5181e48 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,10 @@ yandex_money.log /src/dokumentor/media/ /tmp/ /conf/env +/data/ +/public/ + + !parts +!.gitkeep + diff --git a/Dockerfile b/DockerMakefile similarity index 100% rename from Dockerfile rename to DockerMakefile diff --git a/bin/loaddata.sh b/bin/loaddata.sh new file mode 100755 index 0000000..8e0366d --- /dev/null +++ b/bin/loaddata.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +python src/manage.py loaddata src/myauth/fixtures/myauth.json +python src/manage.py loaddata src/commons/fixtures/cms.json +python src/manage.py loaddata src/commons/fixtures/djangocms_text_ckeditor.json +python src/manage.py loaddata src/commons/fixtures/sites.json +python src/manage.py loaddata src/customer/fixtures/price.json +python src/manage.py loaddata src/docs/fixtures/country.json +python src/manage.py loaddata src/docs/fixtures/currency.json +python src/manage.py loaddata src/docs/fixtures/measure.json diff --git a/compose/Dockerfile.celery.local b/compose/Dockerfile.celery.local new file mode 100644 index 0000000..d9e6b5b --- /dev/null +++ b/compose/Dockerfile.celery.local @@ -0,0 +1,7 @@ +FROM python:3.6 +ENV PYTHONUNBUFFERED 1 +RUN mkdir -p /code/public/ +WORKDIR /code/src +COPY requirements /code/requirements +RUN pip install --upgrade pip && pip install -r ../requirements/local.txt +ADD . /code/ diff --git a/compose/Dockerfile.celery.production b/compose/Dockerfile.celery.production new file mode 100644 index 0000000..3138e29 --- /dev/null +++ b/compose/Dockerfile.celery.production @@ -0,0 +1,7 @@ +FROM python:3.6 +ENV PYTHONUNBUFFERED 1 +RUN mkdir -p /code/public/ +WORKDIR /code/src +COPY requirements /code/requirements +RUN pip install --upgrade pip && pip install -r ../requirements/production.txt +ADD . /code/ diff --git a/compose/Dockerfile.web.local b/compose/Dockerfile.web.local new file mode 100644 index 0000000..bdbc035 --- /dev/null +++ b/compose/Dockerfile.web.local @@ -0,0 +1,8 @@ +FROM python:3.6 +ENV PYTHONUNBUFFERED 1 +RUN mkdir -p /code/public/ +WORKDIR /code +COPY requirements /code/requirements +RUN apt-get update && apt-get -y install ghostscript && apt-get clean +RUN pip install --upgrade pip && pip install -r requirements/local.txt +ADD . /code/ diff --git a/compose/Dockerfile.web.production b/compose/Dockerfile.web.production new file mode 100644 index 0000000..300d31b --- /dev/null +++ b/compose/Dockerfile.web.production @@ -0,0 +1,8 @@ +FROM python:3.6 +ENV PYTHONUNBUFFERED 1 +RUN mkdir -p /code/public/ +WORKDIR /code +COPY requirements /code/requirements +RUN apt-get update && apt-get -y install ghostscript && apt-get clean +RUN pip install --upgrade pip && pip install -r requirements/production.txt +ADD . /code/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2938482 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,61 @@ +version: '2' +services: + + db: + restart: always + image: postgres + container_name: db + environment: + POSTGRES_USER: 'dokumentor' + POSTGRES_PASSWORD: 'dokumentor' + volumes: + - ./data:/var/lib/postgresql/data + + rabbitmq: + restart: always + container_name: rabbitmq + image: rabbitmq:latest + environment: + - RABBITMQ_DEFAULT_USER=dokumentor + - RABBITMQ_DEFAULT_PASS=dokumentor + ports: + - "8080:15672" + - "5672:5672" + - "5671:5671" + + celery: + build: + context: . + dockerfile: compose/Dockerfile.celery.local + container_name: celery + command: bash -c 'celery -A dokumentor worker -l info -E' + volumes: + - .:/code + env_file: conf/env + environment: + DJANGO_DB: 'postgres://dokumentor:dokumentor@db:5432/dokumentor' + CELERY_BROKER_URL: 'amqp://dokumentor:dokumentor@rabbitmq:5672//' + CELERY_RESULT_BACKEND: 'amqp://dokumentor:dokumentor@rabbitmq:5672//' + links: + - db + - rabbitmq + + web: + restart: always + container_name: web + build: + context: . + dockerfile: compose/Dockerfile.web.local + command: bash -c 'python src/manage.py makemigrations && python src/manage.py migrate && python src/manage.py runserver 0.0.0.0:8000' + volumes: + - .:/code + ports: + - "8000:8000" + env_file: conf/env + environment: + DJANGO_DB: 'postgres://dokumentor:dokumentor@db:5432/dokumentor' + CELERY_BROKER_URL: 'amqp://dokumentor:dokumentor@rabbitmq:5672//' + CELERY_RESULT_BACKEND: 'amqp://dokumentor:dokumentor@rabbitmq:5672//' + depends_on: + - db + - rabbitmq diff --git a/requirements/base.txt b/requirements/base.txt index 3b0f960..89f2fd6 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -52,7 +52,6 @@ pyparsing==2.2.0 PyPDF2==1.26.0 python-dateutil==2.6.0 python-memcached==1.58 -python3-ghostscript==0.5.0 pytils==0.3 pytz==2017.2 reportlab==3.4.0 @@ -69,4 +68,5 @@ xlrd==1.0.0 xlutils==2.0.0 xlwt==1.2.0 dj-database-url==0.4.2 -envvars==0.3.0 \ No newline at end of file +envvars==0.3.0 +psycopg2==2.6 \ No newline at end of file diff --git a/requirements/prodaction.txt b/requirements/prodaction.txt deleted file mode 100644 index 5902b98..0000000 --- a/requirements/prodaction.txt +++ /dev/null @@ -1,3 +0,0 @@ --r base.txt -psycopg2==2.6 -gunicorn==19.4.5 \ No newline at end of file diff --git a/requirements/production.txt b/requirements/production.txt new file mode 100644 index 0000000..71fb428 --- /dev/null +++ b/requirements/production.txt @@ -0,0 +1,2 @@ +-r base.txt +gunicorn==19.4.5 \ No newline at end of file diff --git a/requirements/staging.txt b/requirements/staging.txt index 5902b98..71fb428 100644 --- a/requirements/staging.txt +++ b/requirements/staging.txt @@ -1,3 +1,2 @@ -r base.txt -psycopg2==2.6 gunicorn==19.4.5 \ No newline at end of file diff --git a/src/dokumentor/settings/base.py b/src/dokumentor/settings/base.py index a75ca90..46e8409 100644 --- a/src/dokumentor/settings/base.py +++ b/src/dokumentor/settings/base.py @@ -62,15 +62,14 @@ USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/var/www/example.com/media/" -MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media') - +MEDIA_ROOT = os.path.join(ROOT_DIR, 'public', 'media') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://example.com/media/", "http://media.example.com/" MEDIA_URL = '/media/' -STATIC_ROOT = os.path.join(ROOT_DIR, 'static') +STATIC_ROOT = os.path.join(ROOT_DIR, 'public', 'static') # URL prefix for static files. # Example: "http://example.com/static/", "http://static.example.com/" @@ -260,7 +259,6 @@ CELERY_RESULT_BACKEND = e.get('CELERY_RESULT_BACKEND') CELERY_TIMEZONE = 'Europe/Moscow' - CALLBACK_SETTINGS = { 'EMAIL_SENDER': '!DEFINE', 'MANAGERS_EMAILS': ['!DEFINE'], diff --git a/src/dokumentor/templates/base.html b/src/dokumentor/templates/base.html index 56bd6bf..bc4d897 100644 --- a/src/dokumentor/templates/base.html +++ b/src/dokumentor/templates/base.html @@ -136,7 +136,7 @@ -{# {% include 'autocomplete_light/static.html' %}#} + {% include 'autocomplete_light/static.html' %}