some refactor

prod
Dmitriy Shesterkin 9 years ago
parent 92076e9eab
commit 9c3f4bfcdd
  1. 1
      .gitignore
  2. 91
      Dockerfile
  3. 14
      conf/docker/entrypoint.sh
  4. 5
      conf/env.stage
  5. 2
      conf/nginx.conf
  6. 6
      docker-compose.yml
  7. 4
      src/dokumentor/settings/production.py
  8. 37
      src/dokumentor/settings/stage.py

1
.gitignore vendored

@ -9,6 +9,7 @@ conf/env
!.gitkeep
!form.html
/static/vendor
/data/
/deploy/stage.py

@ -1,5 +1,4 @@
FROM python:3.6
ENV PYTHONUNBUFFERED 1
FROM alpine:latest
ENV NGINX_VERSION="1.12.0" \
NGINX_OPTS="--with-http_ssl_module \
@ -10,50 +9,75 @@ ENV NGINX_VERSION="1.12.0" \
--pid-path=/var/run/nginx.pid \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--user=www-data \
--group=www-data \
--user=nginx \
--group=nginx \
--add-module=/tmp/modules/nginx_requestid-master"
COPY requirements /opt/app/requirements
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get -y install ghostscript \
libfreetype6-dev \
python3-dev \
RUN apk update && apk add --update --no-cache --progress \
make \
pcre \
zlib \
libpq \
openssl \
ca-certificates \
python3 \
libmagic \
ghostscript \
postgresql-dev \
supervisor \
git-core \
make && \
apt-get clean && \
libmemcached-dev \
cyrus-sasl-dev \
jpeg libpng freetype \
bash bash-completion \
gettext-dev \
&& apk add --no-cache --virtual=.build-dependencies \
musl-dev \
build-base \
ncurses-dev \
libxslt-dev \
zlib-dev \
pcre-dev \
zlib-dev jpeg-dev libpng-dev freetype-dev \
python3-dev \
&& python3 -m ensurepip \
&& rm -r /usr/lib/python*/ensurepip \
&& pip3 install --upgrade pip setuptools \
&& pip3 install --no-cache-dir -r /opt/app/requirements/production.txt \
# Add nginx group and user
&& addgroup -S nginx \
&& adduser -S nginx -G nginx \
# Download additional nginx modules
mkdir -p /tmp/modules && \
cd /tmp/modules && \
wget -O nginx-requestid.tar.gz https://github.com/hhru/nginx_requestid/archive/master.tar.gz && \
tar xvzf nginx-requestid.tar.gz && \
&& mkdir -p /tmp/modules \
&& cd /tmp/modules \
&& wget -O nginx-requestid.tar.gz https://github.com/hhru/nginx_requestid/archive/master.tar.gz \
&& tar xvzf nginx-requestid.tar.gz \
# Download and compile nginx
cd /tmp && \
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar xzvf nginx-${NGINX_VERSION}.tar.gz && \
cd nginx-${NGINX_VERSION} && \
./configure ${NGINX_OPTS} && \
make && \
make install && \
pip install --upgrade pip && \
pip install --no-cache-dir -r /opt/app/requirements/production.txt && \
&& cd /tmp \
&& wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar xzvf nginx-${NGINX_VERSION}.tar.gz \
&& cd nginx-${NGINX_VERSION} \
&& ./configure ${NGINX_OPTS} \
&& make \
&& make install \
# Delete build dependencies after use
cd /tmp \
&& cd /tmp \
&& apk del .build-dependencies \
&& rm -rf \
modules \
nginx-${NGINX_VERSION} \
nginx-${NGINX_VERSION}.tar.gz \
/var/cache/apt/* \
/var/cache/apk/* \
/root/.cache \
/var/lib/apt/lists/*
# for gitlab cli
# Security precautions
&& openssl rand -base64 32 > /opt/app/secret_key.txt \
&& echo "root:$(openssl passwd -apr1 uztOsdwP)" >> /etc/nginx/.htpasswd
#COPY . /opt/app
#VOLUME ["/opt/app/public/media"]
WORKDIR /opt/app
@ -61,5 +85,8 @@ WORKDIR /opt/app
RUN rm -v /etc/nginx/nginx.conf
ADD /conf/nginx.conf /etc/nginx/
EXPOSE 80
CMD ["conf/docker/entrypoint_stage.sh"]

@ -1,14 +0,0 @@
#!/usr/bin/env bash
# Make database migrations
echo "Make database migrations"
python manage.py migrate makemigrations
# Apply database migrations
echo "Apply database migrations"
python manage.py migrate myauth --noinput
python manage.py migrate --noinput
cd /opt/app
exec "$@"

@ -5,7 +5,10 @@ SSL=False
DJANGO_SECRET='ewfrevwavrvq3tg4wvf3tvw4ug97hf3t48w7hfy3rf32'
DJANGO_DB='postgres://dokumentor:dokumentor@db:5432/dokumentor'
DJANGO_TEST_DB='sqlite:////opt/app/test_db.sqlite3'
# Flower settings
FLOWER_PORT=5555
FLOWER_BASIC_AUTH=dokumentor:dokumentor
DJANGO_FROM_EMAIL='Открытые технологии <no-reply@o-tech.io>'
DJANGO_EMAIL_HOST='smtp.yandex.ru'

@ -1,6 +1,6 @@
worker_processes 1;
user www-data;
user nginx;
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log;

@ -21,13 +21,13 @@ services:
db:
restart: always
container_name: dokumentor-db
image: postgres:latest
image: kiasaki/alpine-postgres:9.5
expose:
- "5432"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./db:/var/lib/postgresql/data
- ./data/postgresql:/var/lib/postgresql/data
environment:
- POSTGRES_USER=dokumentor
- POSTGRES_PASSWORD=dokumentor
@ -58,7 +58,7 @@ services:
bower:
container_name: dokumentor-bower
image: digitallyseamless/nodejs-bower-grunt
image: chrisgeorge/alpine-bower
command: bash -c "cd /opt/app && bower i"
volumes:
- ./:/opt/app

@ -8,7 +8,9 @@ from src.dokumentor.settings.common import *
DEBUG = False
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
ADMINS = []
ADMINS = [
('Александр Костенко', 'alexander.time@gmail.com'),
]
MANAGERS = ADMINS

@ -18,16 +18,37 @@ MANAGERS = ADMINS
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': dj_database_url.parse(e.get('DJANGO_DB')),
'default': dj_database_url.parse('postgres://dokumentor:dokumentor@db:5432/dokumentor'),
}
DEFAULT_FROM_EMAIL = e.get('DJANGO_FROM_EMAIL')
DEFAULT_FROM_EMAIL = 'Открытые технологии <no-reply@o-tech.io>'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_HOST = e.get('DJANGO_EMAIL_HOST')
EMAIL_PORT = e.get('DJANGO_EMAIL_PORT')
EMAIL_HOST_USER = e.get('DJANGO_EMAIL_USER')
EMAIL_HOST_PASSWORD = e.get('DJANGO_EMAIL_PASSWORD')
EMAIL_USE_TLS = e.get('DJANGO_EMAIL_USE_TLS')
EMAIL_USE_SSL = e.get('DJANGO_EMAIL_USE_SSL')
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'no-reply@o-tech.io'
EMAIL_HOST_PASSWORD = 'BA4BnshqVz3Hae'
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
EMAIL_SUBJECT_PREFIX = 'dokumentor '
REDIS_URL = 'redis://redis:6379/1'
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
BROKER_URL = 'amqp://dokumentor:dokumentor@rabbitmq:5672//'
CELERY_RESULT_BACKEND = 'amqp://dokumentor:dokumentor@rabbitmq:5672//'
CALLBACK_SETTINGS = {
'EMAIL_SENDER': 'Документор <no-reply@o-tech.io>',
'MANAGERS_EMAILS': ('mitri4@bk.ru', 'alexander.time@gmail.com', 'dmitriy.shesterkin@gmail.com'),
'NEW_REQ_AVAIL_EMAIL_SUBJ': u'Вопрос техподдержке',
}

Loading…
Cancel
Save