diff --git a/.gitignore b/.gitignore index 620ee544..643a8f54 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ collected_static # gulp node_modules npm-debug.log +data diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..187cc48b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM python:2.7.13 + +ENV PYTHONUNBUFFERED 1 +ENV LANG ru_RU.UTF-8 + +RUN apt-get update \ + \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + \ + build-essential \ + libtiff5-dev \ + libjpeg62-turbo-dev \ + zlib1g-dev \ + libfreetype6-dev \ + liblcms2-dev \ + libwebp-dev \ + tcl8.5-dev \ + tk8.5-dev \ + python-tk \ + pngquant \ + gifsicle \ + libmemcached-dev \ + locales \ + \ + && rm -rf /var/lib/apt/lists/* +RUN sed -i -e 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \ + echo 'LANG="ru_RU.UTF-8"'>/etc/default/locale && \ + dpkg-reconfigure --frontend=noninteractive locales && \ + update-locale LANG=ru_RU.UTF-8 +RUN mkdir /code +WORKDIR /code +ADD requirements.txt /code/ +RUN pip install -r requirements.txt +ADD . /code/ +# docker rmi $(docker images -q -f dangling=true) diff --git a/README.md b/README.md index 763a9e38..455a5463 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,6 @@ RAVEN_CONFIG = { # -*- coding: utf-8 -*- from settings import * -DEBUG = True -# emencia.django.newsletter -LOCAL_DEV = True # sorl.thumbnail THUMBNAIL_DEBUG = True @@ -56,8 +53,6 @@ TEMPLATE_LOADERS = ( 'django.template.loaders.app_directories.Loader', ) -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' - INSTALLED_APPS += ('south',) # debug_toolbar settings diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..47838ead --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,56 @@ +version: '2' + +services: + web: + restart: always + container_name: exmap-web + build: . + command: /bin/bash -c "python manage.py runserver 0.0.0.0:8000" + volumes: + - .:/code + ports: + - "8000:8000" + links: + - mysql:exmap-mysql + - redis:exmap-redis + - elastic:exmap-elastic + environment: + - DEBUG=True + - LOCAL_DEV=True + - REDIS_HOST=redis + - REDIS_PORT=6379 + - MYSQL_HOST=mysql + - MYSQL_USER=root + - MYSQL_PASSWORD=root + - MYSQL_DATABASE=expomap + - ELASTICSEARCH_HOST=elastic + - EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend + + mysql: + restart: always + image: mysql:5.5.57 + container_name: exmap-mysql + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_DATABASE=expomap + ports: + - "3305:3306" + volumes: + - ./data/mysql/db:/var/lib/mysql + + redis: + restart: always + image: redis:3.2.10 + container_name: exmap-redis + volumes: + - ./data/redis:/var/lib/redis + + elastic: + restart: always + image: elasticsearch:2.4.6 + container_name: exmap-elastic + ports: + - 9200:9200 + - 9300:9300 + volumes: + - ./data/elasticsearch:/usr/share/elasticsearch/data diff --git a/proj/settings.py b/proj/settings.py index 50da10c4..469ecbe8 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -14,7 +14,11 @@ SITE_ROOT = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] # Adding modules directory to python path sys.path.insert(0, os.path.join(SITE_ROOT, 'apps')) -DEBUG = True +DEBUG = False +if os.environ.get('DEBUG') == 'True': + DEBUG = True + +LOCAL_DEV = os.environ.get('DEBUG', False) ADMINS = ( @@ -26,10 +30,10 @@ MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'expomap', - 'USER': 'kotzilla', - 'PASSWORD': 'qazedc', - 'HOST': '', + 'NAME': os.environ.get('MYSQL_DATABASE'), + 'USER': os.environ.get('MYSQL_USER'), + 'PASSWORD': os.environ.get('MYSQL_PASSWORD'), + 'HOST': os.environ.get('MYSQL_HOST'), 'PORT': '', 'TEST_CHARSET': 'utf8', } @@ -39,7 +43,7 @@ DATABASES = { CACHES = { "default": { "BACKEND": "redis_cache.RedisCache", - "LOCATION": "localhost:6379", + "LOCATION": "%s:%s" % (os.environ.get('REDIS_HOST'), os.environ.get('REDIS_PORT')), 'OPTIONS': { 'CLIENT_CLASS': 'redis_cache.client.DefaultClient', } @@ -224,7 +228,9 @@ LOGIN_URL='/' #registration info ACCOUNT_ACTIVATION_DAYS=2 # mail settings -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_BACKEND = os.environ.get( + 'EMAIL_BACKEND', 'django.core.mail.backends.smtp.EmailBackend' +) EMAIL_HOST = 'mail.expomap.ru' EMAIL_HOST_USER = 'noreply@expomap.ru' EMAIL_HOST_PASSWORD = 'Very$tr0ngPa$$word' @@ -433,8 +439,9 @@ PYMORPHY_DICTS = { # search backend HAYSTACK_CONNECTIONS = { 'default': { - 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', - 'URL': 'http://localhost:8983/solr' + 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', + 'URL': 'http://%s:9200/' % os.environ.get('ELASTICSEARCH_HOST'), + 'INDEX_NAME': 'haystack', }, } @@ -504,6 +511,9 @@ RECAPTCHA_PUBLIC_KEY = '6LffshgUAAAAALQSBrZusJgfqNsREZbiL9ZT4Jlv' RECAPTCHA_PRIVATE_KEY = '6LffshgUAAAAAF7zZnMbONB36CmOueKKD097UvMg' NOCAPTCHA = True +if not os.path.exists(MEDIA_ROOT + '/upload'): + os.makedirs(MEDIA_ROOT + '/upload') + try: from proj.local import * except ImportError, e: diff --git a/requirements.txt b/requirements.txt index ccab8019..b52c1dd5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -39,6 +39,7 @@ pandas==0.19.2 phonenumbers==6.0.0 Pillow==3.4.2 polib==1.0.8 +pyelasticsearch==1.4 pylibmc==1.2.3 pymorphy==0.5.6 pymorphy2==0.8