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