add Dockerfile

This commit is contained in:
Aleksei Krugliak 2022-05-05 21:16:47 +04:00
parent fc133973f1
commit 8ae5b3a93c
33 changed files with 27 additions and 6 deletions

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM python:3.8 AS builder
COPY requirements.txt .
# install dependencies to the local user directory (eg. /root/.local)
RUN pip install --user -r requirements.txt
# second stage
FROM python:3.8-slim
WORKDIR /code
# copy only the dependencies that are needed for our application and the source files
COPY --from=builder /root/.local /root/.local
COPY ./src .
# update PATH
ENV PATH=/root/.local:$PATH
# make sure you include the -u flag to have our stdout logged
# CMD [ "python", "-u", "./main.py" ]
EXPOSE 8080
# CMD [ "bash", "./run.sh" ]
CMD [ "python", "app.py" ]

5
run.sh
View File

@ -1,4 +1 @@
#!/bin/bash sudo podman run -d --name expense-bot --restart always localhost/expense-bot:0.1.0
source ./venv/bin/activate
python3 app.py

View File

View File

@ -1,10 +1,12 @@
from aiogram import types from aiogram import types
from loader import dp from loader import dp
import sqlite3 as sl
@dp.message_handler(commands="add") @dp.message_handler(commands="add")
async def bot_add(message: types.Message): async def bot_add(message: types.Message):
await message.answer(f"This is ADD command, {message.from_user.username}!") await message.answer(f"This is ADD command, {message.from_user.username}!")
con = sl.connect('test.db')
# @dp.message_handler(state=None) # todo сделать стейты. сейчас это хэндлит все сообщения в любых состояниях! # @dp.message_handler(state=None) # todo сделать стейты. сейчас это хэндлит все сообщения в любых состояниях!
# async def bot_add_parse_message(message: types.Message): # async def bot_add_parse_message(message: types.Message):