Use 2 docker containers for bot and webservice

This commit is contained in:
Administrator 2022-03-12 20:02:39 +01:00
parent 5002d8509b
commit fdd7bc2d4c
14 changed files with 48 additions and 16 deletions

View File

@ -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

View File

@ -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
View 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"]

View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
python bot.py

View File

@ -0,0 +1 @@
pyTelegramBotAPI~=4.4.0

View File

@ -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

View File

@ -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__)

View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
curl -s http://localhost:80/ -o /dev/null || exit 1

View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
nginx -g "daemon off;" &
uwsgi --ini deploy/uwsgi.ini

View File

@ -2,4 +2,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