diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eafcf23..bdc7adf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - build - deploy-dev -# - deploy-prod + - deploy-prod variables: SOLUTIONS_ROOT_EXTERNAL: "/sprint-data/data/solutions" @@ -9,7 +9,7 @@ variables: build: stage: build tags: - - main + - demo before_script: - docker login -u mathwave -p $DOCKERHUB_PASSWORD script: @@ -22,8 +22,6 @@ build: before_script: - docker login -u mathwave -p $DOCKERHUB_PASSWORD script: -# - docker-compose up -d -# - docker-compose -f docker-compose-infra.yaml up -d - docker stack deploy -c ./docker-compose-deploy.yaml sprint deploy-dev: @@ -31,7 +29,7 @@ deploy-dev: - .deploy stage: deploy-dev tags: - - main + - demo rules: - if: '$CI_COMMIT_BRANCH == "master"' when: on_success @@ -39,19 +37,25 @@ deploy-dev: variables: PORT: 80 SOLUTIONS_ROOT_EXTERNAL: "/sprint-data/data/solutions" - HOST: "77.246.159.65" + DB_HOST: "82.146.35.103" + RABBIT_HOST: "82.146.35.103" + FS_HOST: "82.146.35.103" + DEBUG: "true" + TELEGRAM_TOKEN: "$TELEGRAM_TOKEN_DEMO" -#deploy-prod: -# extends: -# - .deploy -# stage: deploy-prod -# tags: -# - prod -# only: -# - master -# when: manual -# variables: -# PORT: 443 -# SOLUTIONS_ROOT_EXTERNAL: "/sprint-data/data/solutions" -# DB_HOST: "postgres" -# RABBIT_HOST: "rabbitmq" +deploy-prod: + extends: + - .deploy + stage: deploy-prod + tags: + - main + only: + - master + when: manual + variables: + PORT: 80 + SOLUTIONS_ROOT_EXTERNAL: "/sprint-data/data/solutions" + DB_HOST: "77.246.159.65" + RABBIT_HOST: "77.246.159.65" + FS_HOST: "77.246.159.65" + TELEGRAM_TOKEN: "$TELEGRAM_TOKEN" diff --git a/Main/management/commands/bot.py b/Main/management/commands/bot.py index 33ff98c..6749e8d 100644 --- a/Main/management/commands/bot.py +++ b/Main/management/commands/bot.py @@ -1,3 +1,5 @@ +import os + import telebot from django.contrib.auth.models import User from django.core.management.base import BaseCommand @@ -5,7 +7,7 @@ from telebot.types import Message from Main.models import UserInfo -bot = telebot.TeleBot("1994460106:AAGrGsCZjF6DVG_T-zycELuVfxnWw8x7UyU") +bot = telebot.TeleBot(os.getenv("TELEGRAM_TOKEN")) @bot.message_handler(commands=["start"]) diff --git a/Sprint/settings.py b/Sprint/settings.py index e521c28..a2276ca 100644 --- a/Sprint/settings.py +++ b/Sprint/settings.py @@ -20,8 +20,6 @@ from sentry_sdk.integrations.django import DjangoIntegration BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -HOST = os.getenv("HOST", "77.246.159.65") - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ @@ -29,7 +27,7 @@ HOST = os.getenv("HOST", "77.246.159.65") SECRET_KEY = "-w#*mn6*fa8a=(-c0@klx&$vl%hpiy&l(u*3%0a#2)wdt##(z2" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.getenv('debug', 'true') == 'true' +DEBUG = os.getenv('DEBUG', 'true') == 'true' ALLOWED_HOSTS = ["*"] @@ -88,8 +86,8 @@ DATABASES = { "ENGINE": "django.db.backends.postgresql_psycopg2", "NAME": "sprint", "USER": "postgres", - "PASSWORD": os.getenv("DB_PASSWORD", "password"), - "HOST": HOST, + "PASSWORD": os.getenv("DB_PASSWORD"), + "HOST": os.getenv("DB_HOST"), "PORT": 5432, } } @@ -145,10 +143,10 @@ for root in DATA_ROOT, EXTRA_FILES_ROOT: SOLUTIONS_ROOT = os.path.join(DATA_ROOT, "solutions") -RABBIT_HOST = HOST +RABBIT_HOST = os.getenv("RABBIT_HOST") RABBIT_PORT = 5672 -FS_HOST = "http://" + HOST +FS_HOST = "http://" + os.getenv("FS_HOST") FS_PORT = 5555 # Authentication backends