Compare commits

..

10 Commits

Author SHA1 Message Date
Administrator
e6935d81e1 update configs 2024-10-05 12:05:17 +03:00
612bae7ab0 port 2024-06-10 19:10:42 +03:00
3764ce7ce7 net2 2024-06-10 17:39:48 +03:00
d30a8a1de6 net 2024-06-10 12:52:43 +03:00
1139775e7c nginx 2024-06-10 12:46:48 +03:00
acc26fcbbe fix 2024-06-10 12:32:33 +03:00
d042de69af remove nginx 2024-06-10 11:52:34 +03:00
2bcdc54db4 Update deploy-prod.yaml 2024-03-24 14:32:07 +00:00
Administrator
628e9b9533 update 2024-02-17 00:57:43 +03:00
Administrator
5b703d776c add staff info 2024-02-17 00:52:39 +03:00
8 changed files with 36 additions and 75 deletions

View File

@ -4,22 +4,9 @@ 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:
- net
- common-infra-nginx
environment:
DB_HOST: "pg.develop.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_DEV
@ -32,9 +19,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:8000
command: runserver 0.0.0.0:1238
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
retries: 5
start_period: 10s
@ -49,8 +36,6 @@ services:
fetch_stats:
image: mathwave/sprint-repo:platform
networks:
- net
environment:
DB_HOST: "pg.develop.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_DEV
@ -89,7 +74,5 @@ services:
order: start-first
networks:
net:
driver: overlay
common-infra-nginx:
external: true

View File

@ -4,26 +4,9 @@ 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:
- net
- common-infra-nginx
environment:
DB_HOST: "pg.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_PROD
@ -37,9 +20,9 @@ services:
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
TELEGRAM_TOKEN: $TELEGRAM_TOKEN
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
command: runserver 0.0.0.0:8000
command: runserver 0.0.0.0:1238
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
retries: 5
start_period: 10s
@ -50,7 +33,7 @@ services:
condition: any
placement:
constraints:
# - node.role == worker
- node.role == worker
- node.labels.zone == ru
update_config:
parallelism: 1
@ -58,8 +41,6 @@ services:
fetch_stats:
image: mathwave/sprint-repo:platform
networks:
- net
environment:
DB_HOST: "pg.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_PROD
@ -94,16 +75,10 @@ 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

View File

@ -15,9 +15,7 @@ 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:

View File

@ -20,10 +20,8 @@ class ConfigsView(BaseView):
return '/configs/?stage=production'
self.stage = self.request.GET['stage']
self.context['stage'] = self.stage
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
self.context['configs'] = Config.objects.filter(project=self.request.user.selected_project,
stage=self.stage).order_by('name')
def post_create_config(self):
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):
data = self.request.POST['data']
config = Config.objects.get(id=self.request.POST['config'])
try:
data = loads(data)
except:
return '/configs?error=config_is_not_json'
config = Config.objects.get(id=self.request.POST['config'])
self.context['incorrect_config'] = config
self.context['incorrect_data'] = data
self.context['error'] = True
return
config.data = data
config.save()
return '/configs/?stage=' + config.stage

View File

@ -1,2 +0,0 @@
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

View File

@ -1,11 +0,0 @@
events {}
http {
client_max_body_size 150m;
server {
listen 1238;
location / {
proxy_pass http://app:8000/;
}
}
}

View File

@ -28,7 +28,7 @@
</div>
{% if error %}
<div class="alert alert-danger" role="alert">
Конфиг не имеет вид JSON!
Конфиг {{ incorrect_config.name }} не имеет вид 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;" 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 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">Удалить</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>
</div>
</form>

View File

@ -3,6 +3,7 @@ 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):
@ -14,10 +15,26 @@ 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}
'experiments': {experiment.name: {'enabled': experiment.enabled, 'condition': experiment.condition} for experiment in experiments},
'platform_staff': platform_staff,
},
safe=False,
)