Merge branch 'master' of https://gitlab.com/lilcity/backend into feature/LIL-523
commit
981b5f4751
36 changed files with 517 additions and 84 deletions
@ -1,16 +1,68 @@ |
|||||||
stages: |
stages: |
||||||
- deploy |
- deploy |
||||||
|
- db |
||||||
|
- stop |
||||||
|
|
||||||
|
variables: |
||||||
|
REVIEW_DOMAIN: back-review.lil.school |
||||||
|
|
||||||
deploy_prod: |
deploy_prod: |
||||||
stage: deploy |
stage: deploy |
||||||
script: |
script: |
||||||
- rsync -a --stats --delete --exclude="docker/data/" --exclude="docker/.env" ./ /work/www/lil.school/ |
- rsync -a --stats --delete --exclude="docker/data/" --exclude="docker/.env" ./ /work/www/lil.school/ |
||||||
- cd /work/www/lil.school/docker/ |
- cd /work/www/lil.school/docker/ |
||||||
- docker-compose -f docker-compose-prod.yml up --build -d |
- docker-compose -f docker-compose-prod.yml -p back up --build -d |
||||||
environment: |
environment: |
||||||
name: prod/site |
name: prod |
||||||
url: https://lil.school |
url: https://lil.school |
||||||
only: |
only: |
||||||
- master |
- master |
||||||
tags: |
tags: |
||||||
- prod |
- prod |
||||||
|
|
||||||
|
deploy_review: |
||||||
|
stage: deploy |
||||||
|
script: |
||||||
|
- export REVIEW_HOST=$CI_COMMIT_REF_SLUG-$REVIEW_DOMAIN |
||||||
|
- cd docker |
||||||
|
- cp .env.review .env |
||||||
|
- docker-compose -f docker-compose-review.yml -p back$CI_COMMIT_REF_NAME up --build -d |
||||||
|
environment: |
||||||
|
name: review/$CI_COMMIT_REF_SLUG |
||||||
|
url: https://$CI_COMMIT_REF_SLUG-$REVIEW_DOMAIN |
||||||
|
on_stop: stop-review |
||||||
|
tags: |
||||||
|
- review |
||||||
|
only: |
||||||
|
- branches |
||||||
|
|
||||||
|
stop-review: |
||||||
|
stage: stop |
||||||
|
environment: |
||||||
|
name: review/$CI_COMMIT_REF_SLUG |
||||||
|
action: stop |
||||||
|
script: |
||||||
|
- export REVIEW_HOST=$CI_COMMIT_REF_SLUG-$REVIEW_DOMAIN |
||||||
|
- cd docker |
||||||
|
- docker-compose -f docker-compose-review.yml -p back$CI_COMMIT_REF_NAME down |
||||||
|
- rm -rf /work/data/back_${CI_COMMIT_REF_NAME}/ |
||||||
|
when: manual |
||||||
|
only: |
||||||
|
- branches |
||||||
|
tags: |
||||||
|
- review |
||||||
|
|
||||||
|
prod-db: |
||||||
|
stage: db |
||||||
|
script: |
||||||
|
- export REVIEW_HOST=$CI_COMMIT_REF_SLUG-$REVIEW_DOMAIN |
||||||
|
- cd docker |
||||||
|
- cp .env.review .env |
||||||
|
- docker-compose -f docker-compose-review.yml -p back$CI_COMMIT_REF_NAME restart db |
||||||
|
- echo 'DROP DATABASE IF EXISTS lilcity; CREATE DATABASE lilcity' | docker-compose -f docker-compose-review.yml -p back$CI_COMMIT_REF_NAME exec -T -u postgres db psql postgres |
||||||
|
- /work/scripts/get_prod_db.sh | docker-compose -f docker-compose-review.yml -p back$CI_COMMIT_REF_NAME exec -T -u postgres db psql lilcity |
||||||
|
when: manual |
||||||
|
only: |
||||||
|
- branches |
||||||
|
tags: |
||||||
|
- review |
||||||
|
|||||||
@ -0,0 +1,50 @@ |
|||||||
|
import requests |
||||||
|
|
||||||
|
from paymentwall import Pingback |
||||||
|
|
||||||
|
from django.conf import settings |
||||||
|
from django.core.management.base import BaseCommand, CommandError |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
help = 'Update statuses on Roistat' |
||||||
|
|
||||||
|
def handle(self, *args, **options): |
||||||
|
body = [ |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_REGULAR), |
||||||
|
'name': 'PINGBACK_TYPE_REGULAR', |
||||||
|
'type': 'paid', |
||||||
|
}, |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_GOODWILL), |
||||||
|
'name': 'PINGBACK_TYPE_GOODWILL', |
||||||
|
'type': 'paid', |
||||||
|
}, |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_NEGATIVE), |
||||||
|
'name': 'PINGBACK_TYPE_NEGATIVE', |
||||||
|
'type': 'canceled', |
||||||
|
}, |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_RISK_UNDER_REVIEW), |
||||||
|
'name': 'PINGBACK_TYPE_RISK_UNDER_REVIEW', |
||||||
|
'type': 'progress', |
||||||
|
}, |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED), |
||||||
|
'name': 'PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED', |
||||||
|
'type': 'paid', |
||||||
|
}, |
||||||
|
{ |
||||||
|
'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_DECLINED), |
||||||
|
'name': 'PINGBACK_TYPE_RISK_REVIEWED_DECLINED', |
||||||
|
'type': 'canceled', |
||||||
|
}, |
||||||
|
] |
||||||
|
project = settings.ROISTAT_PROJECT |
||||||
|
key = settings.ROISTAT_KEY |
||||||
|
url = settings.ROISTAT_API_URL + f'/project/set-statuses?key={key}&project={project}' |
||||||
|
resp = requests.post(url, json=body) |
||||||
|
self.stdout.write(str(resp)) |
||||||
|
self.stdout.write(str(resp.json())) |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
# Generated by Django 2.0.7 on 2018-07-06 07:53 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('payment', '0018_auto_20180512_1202'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AddField( |
||||||
|
model_name='payment', |
||||||
|
name='roistat_visit', |
||||||
|
field=models.PositiveIntegerField(editable=False, null=True, verbose_name='Номер визита Roistat'), |
||||||
|
), |
||||||
|
] |
||||||
@ -0,0 +1,32 @@ |
|||||||
|
import requests |
||||||
|
|
||||||
|
from django.conf import settings |
||||||
|
from django.contrib.auth import get_user_model |
||||||
|
from django.core.management.base import BaseCommand, CommandError |
||||||
|
|
||||||
|
# User = get_user_model() |
||||||
|
|
||||||
|
from apps.user.models import User |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
help = 'Upload users to Roistat' |
||||||
|
|
||||||
|
def handle(self, *args, **options): |
||||||
|
users_queryset = User.objects.all() |
||||||
|
users = [ |
||||||
|
{ |
||||||
|
'id': str(user.id), |
||||||
|
'name': user.get_full_name(), |
||||||
|
'phone': str(user.phone), |
||||||
|
'email': user.email, |
||||||
|
'birth_date': user.birthday.strftime('%d%m%Y') if user.birthday else None, |
||||||
|
} |
||||||
|
for user in users_queryset |
||||||
|
] |
||||||
|
project = settings.ROISTAT_PROJECT |
||||||
|
key = settings.ROISTAT_KEY |
||||||
|
url = settings.ROISTAT_API_URL + f'/project/clients/import?key={key}&project={project}' |
||||||
|
resp = requests.post(url, json=users) |
||||||
|
self.stdout.write(str(resp)) |
||||||
|
self.stdout.write(str(resp.json())) |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
# DEBUG=True |
||||||
|
ALLOWED_HOSTS=* |
||||||
|
PORT=8000 |
||||||
|
CORS_ORIGIN_WHITELIST=lilcity.9ev.ru:8080 |
||||||
|
LANG=ru_RU.UTF-8 |
||||||
|
POSTGRES_DB=lilcity |
||||||
|
POSTGRES_USER=lilcity |
||||||
|
POSTGRES_PASSWORD=GPVs/E/{5&qe |
||||||
|
DJANGO_SETTINGS_MODULE=project.settings |
||||||
|
DATABASE_SERVICE_HOST=db |
||||||
|
SECRET_KEY=jelm*91lj(_-o20+6^a+bgv!4s6e_efry^#+f#=1ak&s1xr-2j |
||||||
|
MAILGUN_API_KEY=key-ec6af2d43d031d59bff6b1c8fb9390cb |
||||||
|
MAILGUN_SENDER_DOMAIN=mail.9ev.ru |
||||||
|
DEFAULT_FROM_EMAIL=postmaster@mail.9ev.ru |
||||||
|
TWILIO_ACCOUNT=ACdf4a96b776cc764bc3ec0f0e136ba550 |
||||||
|
TWILIO_TOKEN=559a6b1fce121759c9af2dcbb3f755ea |
||||||
|
TWILIO_FROM_PHONE=+37128914409 |
||||||
|
PAYMENTWALL_APP_KEY=d6f02b90cf6b16220932f4037578aff7 |
||||||
|
PAYMENTWALL_SECRET_KEY=4ea515bf94e34cf28646c2e12a7b8707 |
||||||
|
MIXPANEL_TOKEN=79bd6bfd98667ed977737e6810b8abcd |
||||||
|
RAVEN_DSN=https://b545dac0ae0545a1bcfc443326fe5850:6f9c900cef7f4c11b63561030b37d15c@sentry.io/1197254 |
||||||
|
ROISTAT_COUNTER_ID=09db30c750035ae3d70a41d5f10d59ec |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
FROM node:9.11.1-alpine as front |
||||||
|
RUN apk update && apk add python alpine-sdk --no-cache |
||||||
|
WORKDIR /web/ |
||||||
|
ADD ./web/yarn.lock /web/ |
||||||
|
ADD ./web/package.json /web/ |
||||||
|
RUN yarn install |
||||||
|
ADD ./web/ /web/ |
||||||
|
RUN yarn build |
||||||
|
|
||||||
|
FROM python:3.6 |
||||||
|
ENV PYTHONUNBUFFERED 1 |
||||||
|
RUN mkdir /app |
||||||
|
WORKDIR /app |
||||||
|
ADD requirements.txt /app/ |
||||||
|
RUN pip install --no-cache-dir -r requirements.txt |
||||||
|
ADD . /app/ |
||||||
|
COPY --from=front /web/build/ /app/web/build/ |
||||||
|
RUN python manage.py collectstatic --no-input |
||||||
@ -1 +0,0 @@ |
|||||||
/etc/nginx/sites-available/default |
|
||||||
@ -0,0 +1,58 @@ |
|||||||
|
version: '3' |
||||||
|
|
||||||
|
services: |
||||||
|
db: |
||||||
|
image: postgres:10.3-alpine |
||||||
|
restart: always |
||||||
|
env_file: |
||||||
|
- .env |
||||||
|
volumes: |
||||||
|
- /work/data/back_${CI_COMMIT_REF_NAME}/postgres:/var/lib/postgresql/data |
||||||
|
logging: &logging |
||||||
|
driver: "json-file" |
||||||
|
options: |
||||||
|
max-size: "1m" |
||||||
|
max-file: "1" |
||||||
|
networks: |
||||||
|
- internal |
||||||
|
- review |
||||||
|
labels: |
||||||
|
- traefik.enable=false |
||||||
|
|
||||||
|
redis: |
||||||
|
image: redis:4.0.9-alpine |
||||||
|
restart: always |
||||||
|
volumes: |
||||||
|
- /work/data/back_${CI_COMMIT_REF_NAME}/redis:/data |
||||||
|
logging: *logging |
||||||
|
networks: |
||||||
|
- internal |
||||||
|
- review |
||||||
|
labels: |
||||||
|
- traefik.enable=false |
||||||
|
|
||||||
|
app: |
||||||
|
build: |
||||||
|
context: ../ |
||||||
|
dockerfile: docker/Dockerfile |
||||||
|
restart: always |
||||||
|
env_file: |
||||||
|
- .env |
||||||
|
volumes: |
||||||
|
- /work/data/back_${CI_COMMIT_REF_NAME}/media:/app/media |
||||||
|
depends_on: |
||||||
|
- db |
||||||
|
- redis |
||||||
|
logging: *logging |
||||||
|
networks: |
||||||
|
- internal |
||||||
|
- review |
||||||
|
labels: |
||||||
|
- traefik.frontend.rule=Host:${REVIEW_HOST} |
||||||
|
- traefik.docker.network=review |
||||||
|
|
||||||
|
networks: |
||||||
|
internal: |
||||||
|
review: |
||||||
|
external: |
||||||
|
name: review |
||||||
@ -1,5 +1,6 @@ |
|||||||
#!/bin/sh |
#!/bin/sh |
||||||
cd /app |
cd /app |
||||||
|
chown www-data:www-data /app/media |
||||||
python manage.py migrate |
python manage.py migrate |
||||||
#python manage.py loaddata /app/apps/*/fixtures/*.json |
#python manage.py loaddata /app/apps/*/fixtures/*.json |
||||||
python2.7 /usr/bin/supervisord -n |
python2.7 /usr/bin/supervisord -n |
||||||
|
|||||||
Loading…
Reference in new issue