zxc
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
b240bc1bad
commit
54afe573c1
|
|
@ -1,20 +1,38 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
environment {
|
environment {
|
||||||
REGISTRY_URL = "https://proxy.docker.dataekb.ru/local_cache"
|
REGISTRY_URL = "https://proxy.docker.dataekb.ru/local_cache"
|
||||||
IMAGE_NAME = "bot_open_sesam"
|
BOT_IMAGE_NAME = "bot_open_sesam"
|
||||||
IMAGE_TAG = "latest"
|
TUNNEL_IMAGE_NAME = "tunnel_open_sesam"
|
||||||
|
BOT_IMAGE_TAG = "latest"
|
||||||
|
TUNNEL_IMAGE_TAG = "latest"
|
||||||
}
|
}
|
||||||
|
|
||||||
agent { label 'agent_smith'}
|
agent { label 'agent_smith'}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
stage ('push main') {
|
stage ('build bot image and push') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') {
|
docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') {
|
||||||
def customImage = docker.build("proxy.docker.dataekb.ru/local_cache/${IMAGE_NAME}:latest")
|
def BotImage = docker.build(
|
||||||
customImage.push()
|
"${REGISTRY_URL}/${BOT_IMAGE_NAME}:${BOT_IMAGE_TAG}"
|
||||||
|
"-f ./tunnel/Dockerfile.tunnel ."
|
||||||
|
)
|
||||||
|
BotImage.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage ('build tunnel image and push') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') {
|
||||||
|
def TunnelImage = docker.build(
|
||||||
|
"${REGISTRY}/${TUNNEL_IMAGE_NAME}:${TUNNEL_IMAGE_TAG}",
|
||||||
|
"-f ./tunnel/Dockerfile.tunnel ."
|
||||||
|
)
|
||||||
|
TunnelImage.push()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -38,8 +56,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
echo "Оба образа собраны и задеплоены успешно"
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo "Ошибка сборки!"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,39 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- bot_open_sesam_network
|
- bot_open_sesam_network
|
||||||
|
depends_on:
|
||||||
|
tunnel_open_sesam:
|
||||||
|
condition: service_healthy
|
||||||
logging:
|
logging:
|
||||||
driver: "json-file"
|
driver: "json-file"
|
||||||
options:
|
options:
|
||||||
max-size: "10m"
|
max-size: "10m"
|
||||||
max-file: "3"
|
max-file: "3"
|
||||||
|
tunnel_open_sesam:
|
||||||
|
image: proxy.docker.dataekb.ru/local_cache/tunnel_open_sesam:latest
|
||||||
|
container_name: tunnel_open_sesam
|
||||||
|
env_file:
|
||||||
|
- ./.env
|
||||||
|
# environment:
|
||||||
|
# - SSH_HOST=91.194.84.91
|
||||||
|
# - SSH_PORT=22
|
||||||
|
# - SSH_USER=root
|
||||||
|
volumes:
|
||||||
|
# SSH ключ
|
||||||
|
- ~/.ssh/id_rsa:/root/.ssh/id_rsa:ro
|
||||||
|
networks:
|
||||||
|
- bot_open_sesam_network
|
||||||
|
restart: always
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "3"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-z", "localhost", "1080"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
networks:
|
networks:
|
||||||
bot_open_sesam_network:
|
bot_open_sesam_network:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
|
||||||
3
main.py
3
main.py
|
|
@ -14,12 +14,11 @@ from config import config
|
||||||
|
|
||||||
# BOT_TOKEN = config["BOT_TOKEN"]
|
# BOT_TOKEN = config["BOT_TOKEN"]
|
||||||
BOT_TOKEN=os.environ.get('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)
|
||||||
|
|
||||||
PROXY_URL = os.environ.get('PROXY_URL')
|
|
||||||
|
|
||||||
session = AiohttpSession(proxy=PROXY_URL)
|
session = AiohttpSession(proxy=PROXY_URL)
|
||||||
|
|
||||||
async def main() -> None:
|
async def main() -> None:
|
||||||
|
|
|
||||||
|
|
@ -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"]
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
# tunnel/entrypoint.sh
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Права на ключ
|
||||||
|
chmod 600 /root/.ssh/id_rsa
|
||||||
|
|
||||||
|
# Добавляем сервер в known_hosts
|
||||||
|
ssh-keyscan -p ${SSH_PORT:-22} ${SSH_HOST} >> /root/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
|
echo "Запуск AutoSSH туннеля → ${SSH_USER}@${SSH_HOST}:${SSH_PORT:-22}"
|
||||||
|
|
||||||
|
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}
|
||||||
Loading…
Reference in New Issue