Compare commits
10 Commits
3a6ead976f
...
e6935d81e1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e6935d81e1 | ||
612bae7ab0 | |||
3764ce7ce7 | |||
d30a8a1de6 | |||
1139775e7c | |||
acc26fcbbe | |||
d042de69af | |||
2bcdc54db4 | |||
![]() |
628e9b9533 | ||
![]() |
5b703d776c |
@ -4,22 +4,9 @@ version: "3.4"
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
platform-nginx:
|
platform-nginx:
|
||||||
image: mathwave/sprint-repo:platform-nginx
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
- common-infra-nginx
|
|
||||||
deploy:
|
|
||||||
mode: replicated
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
app:
|
|
||||||
image: mathwave/sprint-repo:platform
|
image: mathwave/sprint-repo:platform
|
||||||
networks:
|
networks:
|
||||||
- net
|
- common-infra-nginx
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: "pg.develop.sprinthub.ru"
|
DB_HOST: "pg.develop.sprinthub.ru"
|
||||||
DB_PASSWORD: $DB_PASSWORD_DEV
|
DB_PASSWORD: $DB_PASSWORD_DEV
|
||||||
@ -32,9 +19,9 @@ services:
|
|||||||
VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN
|
VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN
|
||||||
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
|
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
|
||||||
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||||
command: runserver 0.0.0.0:8000
|
command: runserver 0.0.0.0:1238
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: curl --fail http://0.0.0.0:8000/ping || exit 1
|
test: curl --fail http://0.0.0.0:1238/ping || exit 1
|
||||||
interval: 60s
|
interval: 60s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
@ -49,8 +36,6 @@ services:
|
|||||||
|
|
||||||
fetch_stats:
|
fetch_stats:
|
||||||
image: mathwave/sprint-repo:platform
|
image: mathwave/sprint-repo:platform
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: "pg.develop.sprinthub.ru"
|
DB_HOST: "pg.develop.sprinthub.ru"
|
||||||
DB_PASSWORD: $DB_PASSWORD_DEV
|
DB_PASSWORD: $DB_PASSWORD_DEV
|
||||||
@ -89,7 +74,5 @@ services:
|
|||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
net:
|
|
||||||
driver: overlay
|
|
||||||
common-infra-nginx:
|
common-infra-nginx:
|
||||||
external: true
|
external: true
|
@ -4,26 +4,9 @@ version: "3.4"
|
|||||||
services:
|
services:
|
||||||
|
|
||||||
platform-nginx:
|
platform-nginx:
|
||||||
image: mathwave/sprint-repo:platform-nginx
|
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
- common-infra-nginx
|
|
||||||
deploy:
|
|
||||||
mode: replicated
|
|
||||||
restart_policy:
|
|
||||||
condition: any
|
|
||||||
placement:
|
|
||||||
constraints:
|
|
||||||
# - node.role == worker
|
|
||||||
- node.labels.zone == ru
|
|
||||||
update_config:
|
|
||||||
parallelism: 1
|
|
||||||
order: start-first
|
|
||||||
|
|
||||||
app:
|
|
||||||
image: mathwave/sprint-repo:platform
|
image: mathwave/sprint-repo:platform
|
||||||
networks:
|
networks:
|
||||||
- net
|
- common-infra-nginx
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: "pg.sprinthub.ru"
|
DB_HOST: "pg.sprinthub.ru"
|
||||||
DB_PASSWORD: $DB_PASSWORD_PROD
|
DB_PASSWORD: $DB_PASSWORD_PROD
|
||||||
@ -37,9 +20,9 @@ services:
|
|||||||
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
|
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
|
||||||
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
|
||||||
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
|
||||||
command: runserver 0.0.0.0:8000
|
command: runserver 0.0.0.0:1238
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: curl --fail http://0.0.0.0:8000/ping || exit 1
|
test: curl --fail http://0.0.0.0:1238/ping || exit 1
|
||||||
interval: 60s
|
interval: 60s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
@ -50,7 +33,7 @@ services:
|
|||||||
condition: any
|
condition: any
|
||||||
placement:
|
placement:
|
||||||
constraints:
|
constraints:
|
||||||
# - node.role == worker
|
- node.role == worker
|
||||||
- node.labels.zone == ru
|
- node.labels.zone == ru
|
||||||
update_config:
|
update_config:
|
||||||
parallelism: 1
|
parallelism: 1
|
||||||
@ -58,8 +41,6 @@ services:
|
|||||||
|
|
||||||
fetch_stats:
|
fetch_stats:
|
||||||
image: mathwave/sprint-repo:platform
|
image: mathwave/sprint-repo:platform
|
||||||
networks:
|
|
||||||
- net
|
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: "pg.sprinthub.ru"
|
DB_HOST: "pg.sprinthub.ru"
|
||||||
DB_PASSWORD: $DB_PASSWORD_PROD
|
DB_PASSWORD: $DB_PASSWORD_PROD
|
||||||
@ -94,16 +75,10 @@ services:
|
|||||||
mode: replicated
|
mode: replicated
|
||||||
restart_policy:
|
restart_policy:
|
||||||
condition: on-failure
|
condition: on-failure
|
||||||
placement:
|
|
||||||
constraints:
|
|
||||||
# - node.role == worker
|
|
||||||
- node.labels.zone == ru
|
|
||||||
update_config:
|
update_config:
|
||||||
parallelism: 1
|
parallelism: 1
|
||||||
order: start-first
|
order: start-first
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
net:
|
|
||||||
driver: overlay
|
|
||||||
common-infra-nginx:
|
common-infra-nginx:
|
||||||
external: true
|
external: true
|
||||||
|
@ -15,9 +15,7 @@ build:
|
|||||||
- .deploy
|
- .deploy
|
||||||
script:
|
script:
|
||||||
- docker build -t mathwave/sprint-repo:platform .
|
- docker build -t mathwave/sprint-repo:platform .
|
||||||
- docker build -t mathwave/sprint-repo:platform-nginx nginx
|
|
||||||
- docker push mathwave/sprint-repo:platform
|
- docker push mathwave/sprint-repo:platform
|
||||||
- docker push mathwave/sprint-repo:platform-nginx
|
|
||||||
|
|
||||||
deploy-dev:
|
deploy-dev:
|
||||||
extends:
|
extends:
|
||||||
|
@ -20,10 +20,8 @@ class ConfigsView(BaseView):
|
|||||||
return '/configs/?stage=production'
|
return '/configs/?stage=production'
|
||||||
self.stage = self.request.GET['stage']
|
self.stage = self.request.GET['stage']
|
||||||
self.context['stage'] = self.stage
|
self.context['stage'] = self.stage
|
||||||
|
self.context['configs'] = Config.objects.filter(project=self.request.user.selected_project,
|
||||||
def get(self):
|
stage=self.stage).order_by('name')
|
||||||
self.context['configs'] = Config.objects.filter(project=self.request.user.selected_project, stage=self.stage).order_by('name')
|
|
||||||
self.context['error'] = 'error' in self.request.GET
|
|
||||||
|
|
||||||
def post_create_config(self):
|
def post_create_config(self):
|
||||||
Config.objects.create(name=self.request.POST['name'], project=self.request.user.selected_project, stage=self.stage)
|
Config.objects.create(name=self.request.POST['name'], project=self.request.user.selected_project, stage=self.stage)
|
||||||
@ -36,11 +34,14 @@ class ConfigsView(BaseView):
|
|||||||
|
|
||||||
def post_save(self):
|
def post_save(self):
|
||||||
data = self.request.POST['data']
|
data = self.request.POST['data']
|
||||||
|
config = Config.objects.get(id=self.request.POST['config'])
|
||||||
try:
|
try:
|
||||||
data = loads(data)
|
data = loads(data)
|
||||||
except:
|
except:
|
||||||
return '/configs?error=config_is_not_json'
|
self.context['incorrect_config'] = config
|
||||||
config = Config.objects.get(id=self.request.POST['config'])
|
self.context['incorrect_data'] = data
|
||||||
|
self.context['error'] = True
|
||||||
|
return
|
||||||
config.data = data
|
config.data = data
|
||||||
config.save()
|
config.save()
|
||||||
return '/configs/?stage=' + config.stage
|
return '/configs/?stage=' + config.stage
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
FROM nginx
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
|
@ -1,11 +0,0 @@
|
|||||||
events {}
|
|
||||||
|
|
||||||
http {
|
|
||||||
client_max_body_size 150m;
|
|
||||||
server {
|
|
||||||
listen 1238;
|
|
||||||
location / {
|
|
||||||
proxy_pass http://app:8000/;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<div class="alert alert-danger" role="alert">
|
<div class="alert alert-danger" role="alert">
|
||||||
Конфиг не имеет вид JSON!
|
Конфиг {{ incorrect_config.name }} не имеет вид JSON!
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
@ -52,11 +52,11 @@
|
|||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<textarea style="width: 100%; height: 800px;" name="data">{{ config.data_pretty }}</textarea>
|
<textarea style="width: 100%; height: 800px;{% if config.id == incorrect_config.id %}border: 1px solid #f00;{% endif %}" name="data">{% if config.id == incorrect_config.id %}{{ incorrect_data }}{% else %}{{ config.data_pretty }}{% endif %}</textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" name="action" value="save" class="btn btn-secondary">Сохранить</button>
|
<button type="submit" name="action" value="save" class="btn btn-secondary">Сохранить</button>
|
||||||
<button type="submit" name="action" value="delete" class="btn btn-danger">Удалить</button>
|
<button type="submit" name="action" value="delete" class="btn btn-danger" onclick="return confirm('Подтверди удаление. Это действие необратимо.');">Удалить</button>
|
||||||
<button type="button" class="btn btn-link text-gray-600 ms-auto" data-bs-dismiss="modal">Закрыть</button>
|
<button type="button" class="btn btn-link text-gray-600 ms-auto" data-bs-dismiss="modal">Закрыть</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -3,6 +3,7 @@ from django.http import HttpResponse, JsonResponse
|
|||||||
from Platform import settings
|
from Platform import settings
|
||||||
from configs.models import Config
|
from configs.models import Config
|
||||||
from experiments.models import Experiment
|
from experiments.models import Experiment
|
||||||
|
from web.models import CustomUser
|
||||||
|
|
||||||
|
|
||||||
def fetch(request):
|
def fetch(request):
|
||||||
@ -14,10 +15,26 @@ def fetch(request):
|
|||||||
return HttpResponse('', status=400)
|
return HttpResponse('', status=400)
|
||||||
configs = Config.objects.filter(stage=stage, project__name=project)
|
configs = Config.objects.filter(stage=stage, project__name=project)
|
||||||
experiments = Experiment.objects.filter(stage=stage, project__name=project)
|
experiments = Experiment.objects.filter(stage=stage, project__name=project)
|
||||||
|
platform_staff = {
|
||||||
|
'vk_id': [],
|
||||||
|
'yandex_id': [],
|
||||||
|
'telegram_id': [],
|
||||||
|
'email': [],
|
||||||
|
}
|
||||||
|
for user in CustomUser.objects.filter(is_active=True):
|
||||||
|
if user.vk_id:
|
||||||
|
platform_staff['vk_id'].append(user.vk_id)
|
||||||
|
if user.yandex_id:
|
||||||
|
platform_staff['yandex_id'].append(user.yandex_id)
|
||||||
|
if user.telegram_id:
|
||||||
|
platform_staff['telegram_id'].append(user.telegram_id)
|
||||||
|
if user.email:
|
||||||
|
platform_staff['email'].append(user.email)
|
||||||
return JsonResponse(
|
return JsonResponse(
|
||||||
data={
|
data={
|
||||||
'configs': {config.name: config.data for config in configs},
|
'configs': {config.name: config.data for config in configs},
|
||||||
'experiments': {experiment.name: {'enabled': experiment.enabled, 'condition': experiment.condition} for experiment in experiments}
|
'experiments': {experiment.name: {'enabled': experiment.enabled, 'condition': experiment.condition} for experiment in experiments},
|
||||||
|
'platform_staff': platform_staff,
|
||||||
},
|
},
|
||||||
safe=False,
|
safe=False,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user