Compare commits

...

31 Commits
test ... main

Author SHA1 Message Date
korotkov 78c23227e4 ewq
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 14:49:27 +05:00
korotkov 7b6d298d68 delete id-rsa
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 14:32:43 +05:00
korotkov 1b9649fbc0 q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 14:27:48 +05:00
korotkov 193390ecb8 q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 14:23:12 +05:00
korotkov 55ebed483f q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 14:15:31 +05:00
korotkov 00846331f3 q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 14:14:09 +05:00
korotkov 0adc48209d q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 14:09:47 +05:00
korotkov d7403bb266 q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 13:58:53 +05:00
korotkov 2b43532a8f qa
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 13:37:15 +05:00
korotkov 54afe573c1 zxc
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 13:28:53 +05:00
korotkov b240bc1bad q
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 13:08:56 +05:00
korotkov be996f942b qwe
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 13:00:14 +05:00
korotkov dda0e8ebb7 q
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 12:44:31 +05:00
korotkov dd78a4a55b qq
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 11:39:35 +05:00
korotkov f61e8e1588 qwe
BOT_open_sesam/pipeline/head This commit looks good Details
2026-04-01 11:38:28 +05:00
korotkov 0168036fab qaz
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 11:35:42 +05:00
korotkov 24fdc1014c qwe
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 11:34:39 +05:00
korotkov 5f59c4df92 qw
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 11:26:27 +05:00
korotkov 63ab836f1a q
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 11:20:59 +05:00
korotkov d57a88321e add sock5
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-04-01 11:11:11 +05:00
dl 5b0eafe695 Docker automate in Jenkinsfile (fix 8)
TEST_JD/pipeline/head There was a failure building this commit Details
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:50:00 +05:00
dl 35dca573c9 Docker automate in Jenkinsfile (fix 7)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:44:53 +05:00
dl dc021f6802 Docker automate in Jenkinsfile (fix 6)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:43:05 +05:00
dl 8f8b5d18d1 Docker automate in Jenkinsfile (fix 5)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:34:20 +05:00
dl 7ad9b91a0a Docker automate in Jenkinsfile (fix 4)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:26:33 +05:00
dl 469ab42324 Docker automate in Jenkinsfile (fix 3)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:21:50 +05:00
dl 3547f307b1 Docker automate in Jenkinsfile (fix 2)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:20:25 +05:00
dl 8edd79be72 Docker automate in Jenkinsfile (fix 1)
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:13:28 +05:00
dl e4f596dd82 Docker automate in Jenkinsfile
BOT_open_sesam/pipeline/head There was a failure building this commit Details
2026-02-04 12:06:58 +05:00
korotkov b2363215b8 q
BOT_open_sesam/pipeline/head This commit looks good Details
2026-02-03 16:04:02 +05:00
korotkov 0c060c79cb change .env env variable
BOT_open_sesam/pipeline/head This commit looks good Details
2026-02-03 15:59:00 +05:00
6 changed files with 198 additions and 25 deletions

130
Jenkinsfile vendored
View File

@ -1,23 +1,117 @@
pipeline { pipeline {
agent { label 'agent_smith' } environment {
REGISTRY_URL = "https://proxy.docker.dataekb.ru/local_cache"
stages { REGISTRY = "proxy.docker.dataekb.ru/local_cache"
stage('Stop and Remove Existing Container') { BOT_IMAGE_NAME = "bot_open_sesam"
steps { TUNNEL_IMAGE_NAME = "tunnel_open_sesam"
sh ''' BOT_IMAGE_TAG = "latest"
docker stop open_sesam || true TUNNEL_IMAGE_TAG = "latest"
docker rm open_sesam || true IMAGE_TAG = "${env.BUILD_NUMBER}"
docker-compose down || true
'''
}
} }
stage('Build and Run Container') { agent { label 'agent_smith'}
steps {
sh ''' options {
docker-compose up --build -d buildDiscarder(logRotator(numToKeepStr: '10'))
''' disableConcurrentBuilds() // Prevent cleanup conflicts
} timeout(time: 30, unit: 'MINUTES')
} }
}
stages {
stage ('build bot image and push') {
steps {
script {
docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') {
def BotImage = docker.build(
"${REGISTRY}/${BOT_IMAGE_NAME}:${env.BUILD_NUMBER}",
"--label build_number=${IMAGE_TAG} " +
"--label git_commit=${env.GIT_COMMIT} " +
"."
)
BotImage.push()
}
}
}
}
stage ('build tunnel image and push') {
steps {
dir('tunnel'){
script {
docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') {
def TunnelImage = docker.build(
"${REGISTRY}/${TUNNEL_IMAGE_NAME}:${env.BUILD_NUMBER}",
"--label build_number=${IMAGE_TAG} " +
"--label git_commit=${env.GIT_COMMIT} " +
"."
)
TunnelImage.push()
}
}
}
}
}
stage ('clear after build and push') {
steps {
script {
sh "docker image prune --filter label=stage=builder"
}
}
}
stage("Deploy") {
steps {
script {
sh '''
export BOT_IMAGE_TAG=${IMAGE_TAG}
export TUNNEL_IMAGE_TAG=${IMAGE_TAG}
# Pull new images explicitly
docker-compose pull bot_open_sesam tunnel_open_sesam
# Deploy with specific project name
docker-compose up -d --remove-orphans
'''
}
}
}
}
post {
success {
echo "Оба образа собраны и задеплоены успешно"
}
failure {
echo "Ошибка сборки!"
}
}
} }
// Old_version
// pipeline {
// agent { label 'agent_smith' }
//
// 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
// '''
// }
// }
// }
// }

View File

@ -1,15 +1,52 @@
version: '3' version: '3'
services: services:
open_sesam: bot_open_sesam:
container_name: open_sesam container_name: bot_open_sesam
build: . image: proxy.docker.dataekb.ru/local_cache/bot_open_sesam:${BOT_IMAGE_TAG:-latest}
stdin_open: true stdin_open: true
tty: true tty: true
env_file:
- ./.env
restart: always
networks:
- bot_open_sesam_network
depends_on:
tunnel_open_sesam:
condition: service_healthy
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
tunnel_open_sesam:
image: proxy.docker.dataekb.ru/local_cache/tunnel_open_sesam:${BOT_IMAGE_TAG:-latest}
container_name: tunnel_open_sesam
env_file:
- ./.env
# environment:
# - SSH_HOST=91.194.84.91
# - SSH_PORT=22
# - SSH_USER=root
volumes: volumes:
- ./.env:/bot/open_sesam/.env # SSH ключ
- .ssh/id_rsa:/root/.ssh/id_rsa:ro
networks:
- bot_open_sesam_network
restart: always restart: always
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "10m" max-size: "10m"
max-file: "3" max-file: "3"
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "1080"]
interval: 10s
timeout: 5s
retries: 5
networks:
bot_open_sesam_network:
driver: bridge
ipam:
config:
- subnet: 172.30.10.0/29
gateway: 172.30.10.1

14
main.py
View File

@ -1,22 +1,32 @@
import os
import asyncio import asyncio
import logging import logging
import sys import sys
from aiogram import Bot, Dispatcher from aiogram import Bot, Dispatcher
from aiogram.enums import ParseMode from aiogram.enums import ParseMode
from aiogram.client.default import DefaultBotProperties from aiogram.client.default import DefaultBotProperties
from aiogram.client.session.aiohttp import AiohttpSession
from handlers import register_all_handlers from handlers import register_all_handlers
from config import config from config import config
BOT_TOKEN = config["BOT_TOKEN"] # BOT_TOKEN = config["BOT_TOKEN"]
BOT_TOKEN=os.environ.get('BOT_TOKEN')
PROXY_URL = os.environ.get('PROXY_URL')
dp = Dispatcher() dp = Dispatcher()
register_all_handlers(dp) register_all_handlers(dp)
session = AiohttpSession(proxy=PROXY_URL)
async def main() -> None: async def main() -> None:
bot = Bot(token=BOT_TOKEN, default=DefaultBotProperties(parse_mode=ParseMode.HTML)) bot = Bot(
token=BOT_TOKEN
, session=session
, default=DefaultBotProperties(parse_mode=ParseMode.HTML)
)
await dp.start_polling(bot) await dp.start_polling(bot)

View File

@ -18,3 +18,4 @@ typing-inspection==0.4.0
typing_extensions==4.13.2 typing_extensions==4.13.2
urllib3==2.4.0 urllib3==2.4.0
yarl==1.20.0 yarl==1.20.0
aiohttp-socks

15
tunnel/Dockerfile 100644
View File

@ -0,0 +1,15 @@
# tunnel/Dockerfile
FROM alpine:3.19
RUN apk add --no-cache \
autossh \
openssh-client
# Директория для SSH ключей
RUN mkdir -p /root/.ssh && \
chmod 700 /root/.ssh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -0,0 +1,16 @@
#!/bin/sh
ssh-keyscan -p ${SSH_PORT:-22} ${SSH_HOST} >> /root/.ssh/known_hosts 2>/dev/null
exec autossh \
-M 0 \
-N \
-D 0.0.0.0:1080 \
-o "ServerAliveInterval=30" \
-o "ServerAliveCountMax=3" \
-o "ExitOnForwardFailure=yes" \
-o "StrictHostKeyChecking=no" \
-o "ConnectTimeout=10" \
-p ${SSH_PORT:-22} \
-i /root/.ssh/id_rsa \
${SSH_USER}@${SSH_HOST}