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: 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

View File

@ -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
@ -87,23 +68,17 @@ services:
DB_HOST: "pg.sprinthub.ru" DB_HOST: "pg.sprinthub.ru"
DB_PASSWORD: $DB_PASSWORD_PROD DB_PASSWORD: $DB_PASSWORD_PROD
MINIO_HOST: "minio.sprinthub.ru" MINIO_HOST: "minio.sprinthub.ru"
MINIO_SECRET_KEY: $MINIO_SECRET_KEY_PROD MINIO_SECRET_KEY: $MINIO _SECRET_KEY_PROD
TELEGRAM_TOKEN: $TELEGRAM_TOKEN TELEGRAM_TOKEN: $TELEGRAM_TOKEN
command: migrate command: migrate
deploy: deploy:
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

View File

@ -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:

View File

@ -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

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> </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>

View File

@ -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,
) )