Use 2 docker containers for bot and webservice
This commit is contained in:
parent
5002d8509b
commit
fdd7bc2d4c
21
.drone.yml
21
.drone.yml
@ -5,7 +5,7 @@ name: linux-amd64
|
|||||||
platform:
|
platform:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
os: linux
|
os: linux
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: generate_tag
|
- name: generate_tag
|
||||||
image: golang
|
image: golang
|
||||||
@ -13,7 +13,7 @@ steps:
|
|||||||
- echo -n "${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8}, latest" > .tags
|
- echo -n "${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8}, latest" > .tags
|
||||||
|
|
||||||
|
|
||||||
- name: publish
|
- name: publish_webservice
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
username:
|
username:
|
||||||
@ -23,8 +23,21 @@ steps:
|
|||||||
registry:
|
registry:
|
||||||
from_secret: registry
|
from_secret: registry
|
||||||
repo:
|
repo:
|
||||||
from_secret: repo
|
from_secret: repo_webservice
|
||||||
dockerfile: Dockerfile
|
dockerfile: webservice/Dockerfile
|
||||||
|
|
||||||
|
- name: publish_bot
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: username
|
||||||
|
password:
|
||||||
|
from_secret: password
|
||||||
|
registry:
|
||||||
|
from_secret: registry
|
||||||
|
repo:
|
||||||
|
from_secret: repo_bot
|
||||||
|
dockerfile: telegram_bot/Dockerfile
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
#nginx -g "daemon off;" &
|
|
||||||
#uwsgi --ini deploy/uwsgi.ini
|
|
||||||
|
|
||||||
python3 app.py
|
|
17
telegram_bot/Dockerfile
Normal file
17
telegram_bot/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM python:3.10-alpine
|
||||||
|
|
||||||
|
WORKDIR /srv/flask_app
|
||||||
|
|
||||||
|
COPY requirements.txt /srv/flask_app/
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
|
||||||
|
|
||||||
|
COPY .. /srv/flask_app
|
||||||
|
RUN chmod +x ./deploy/start.sh
|
||||||
|
RUN chmod +x ./deploy/healthcheck.sh
|
||||||
|
|
||||||
|
# HEALTHCHECK --interval=15s --timeout=2s CMD ["./deploy/healthcheck.sh"]
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD ["./deploy/start.sh"]
|
2
telegram_bot/deploy/start.sh
Normal file
2
telegram_bot/deploy/start.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
python bot.py
|
1
telegram_bot/requirements.txt
Normal file
1
telegram_bot/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
pyTelegramBotAPI~=4.4.0
|
@ -7,7 +7,7 @@ COPY requirements.txt /srv/flask_app/
|
|||||||
|
|
||||||
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
|
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
|
||||||
|
|
||||||
COPY . /srv/flask_app
|
COPY .. /srv/flask_app
|
||||||
COPY deploy/nginx.conf /etc/nginx
|
COPY deploy/nginx.conf /etc/nginx
|
||||||
RUN chmod +x ./deploy/start.sh
|
RUN chmod +x ./deploy/start.sh
|
||||||
RUN chmod +x ./deploy/healthcheck.sh
|
RUN chmod +x ./deploy/healthcheck.sh
|
@ -3,7 +3,7 @@ import time
|
|||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
from bot import bot
|
from telegram_bot.bot import bot
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
2
webservice/deploy/healthcheck.sh
Normal file
2
webservice/deploy/healthcheck.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
curl -s http://localhost:80/ -o /dev/null || exit 1
|
3
webservice/deploy/start.sh
Normal file
3
webservice/deploy/start.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
nginx -g "daemon off;" &
|
||||||
|
uwsgi --ini deploy/uwsgi.ini
|
@ -1,5 +1,4 @@
|
|||||||
Flask~=2.0.3
|
Flask~=2.0.3
|
||||||
python-dotenv==0.19.2
|
python-dotenv==0.19.2
|
||||||
requests==2.27.1
|
requests==2.27.1
|
||||||
uwsgi==2.0.20
|
uwsgi==2.0.20
|
||||||
pyTelegramBotAPI~=4.4.0
|
|
Loading…
Reference in New Issue
Block a user