init_config создан для проверки и создания .env. Jenkinsfile docker-compose.yml dockerfile были добавлены для автоматического развертывания
BOT_open_sesam/pipeline/head There was a failure building this commit
Details
BOT_open_sesam/pipeline/head There was a failure building this commit
Details
parent
6656736758
commit
d1096540f8
|
|
@ -0,0 +1,23 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Stop and Remove Existing Container') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
docker stop open_sesam || true
|
||||||
|
docker rm open_sesam || true
|
||||||
|
docker-compose down || true
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build and Run Container') {
|
||||||
|
steps {
|
||||||
|
sh '''
|
||||||
|
docker-compose up --build -d
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
telegram-bot:
|
||||||
|
build: .
|
||||||
|
container_name: open_sesam
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
restart: always
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
FROM python:3.13.3-slim
|
||||||
|
|
||||||
|
WORKDIR /bot/open_sesam
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --upgrade pip && pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["python, main.py"]
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
||||||
|
ENV_FILE = ".env"
|
||||||
|
|
||||||
|
|
||||||
|
def check_env_file():
|
||||||
|
return os.path.exists(ENV_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
def create_env_file():
|
||||||
|
print("Файл .env отсутствует и будет создан автоматически.")
|
||||||
|
|
||||||
|
token = input("Введите TOKEN: ")
|
||||||
|
lock_ip = input("Введите LOCK_IP: ")
|
||||||
|
card_id = input("Введите CARD_ID: ")
|
||||||
|
auth_api = input("Введите AUTH_API: ")
|
||||||
|
|
||||||
|
with open(ENV_FILE, "w") as f:
|
||||||
|
f.write(f"TOKEN={token}\n")
|
||||||
|
f.write(f"LOCK_IP={lock_ip}\n")
|
||||||
|
f.write(f"CARD_ID={card_id}\n")
|
||||||
|
f.write(f"AUTH_API={auth_api}\n")
|
||||||
|
|
||||||
|
print("Файл .env создан. Происходит запуск приложения")
|
||||||
|
|
||||||
|
|
||||||
|
def load_env():
|
||||||
|
load_dotenv()
|
||||||
7
main.py
7
main.py
|
|
@ -11,12 +11,15 @@ from aiogram.enums import ParseMode
|
||||||
from aiogram import F
|
from aiogram import F
|
||||||
|
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from dotenv import load_dotenv
|
|
||||||
|
|
||||||
from buttons import FBI_open_up
|
from buttons import FBI_open_up
|
||||||
|
from init_config import check_env_file, create_env_file, load_env
|
||||||
|
|
||||||
|
|
||||||
load_dotenv()
|
if not check_env_file():
|
||||||
|
create_env_file()
|
||||||
|
|
||||||
|
load_env()
|
||||||
|
|
||||||
TOKEN = getenv("TOKEN")
|
TOKEN = getenv("TOKEN")
|
||||||
dp = Dispatcher()
|
dp = Dispatcher()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue