Skip to content

Commit 75ed944

Browse files
committed
docker support
1 parent 0700f73 commit 75ed944

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/*.db
2+
**/logs

.github/workflows/python-app.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ jobs:
4646
key: ${{ secrets.SERVER_SSH_KEY }}
4747
script: |
4848
cd ~/TFinance
49-
git reset --hard origin/main
49+
git reset --hard origin/main
5050
git pull origin main
51-
source venv/bin/activate
52-
pip3 install -r requirements/prod.txt
53-
cd ~/TFinance/tfinance
54-
python3 main.py
55-
deactivate
56-
cd ~
51+
docker compose down -v
52+
docker compose up --build -d

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.12.4-slim
2+
3+
RUN apt update
4+
5+
COPY ./requirements /requirements
6+
RUN pip install -r requirements/prod.txt
7+
RUN rm -rf requirements
8+
9+
COPY ./tfinance /tfinance/
10+
WORKDIR /tfinance
11+
12+
CMD ["python", "main.py"]

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "tfinance"
2+
3+
services:
4+
main_tfinance:
5+
build: .
6+
container_name: tfinance
7+
env_file:
8+
- ./.env
9+
restart: always
10+
volumes:
11+
- ./for_docker/logs:/tfinance/logs
12+
- ./for_docker/:/tfinance/data.db

tfinance/database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sqlite3
23

34
from models import User
@@ -22,7 +23,7 @@ class Database:
2223

2324
def __init__(self):
2425
# Подключение к БД с отключенной проверкой потока.
25-
self.con = sqlite3.connect("data.db", check_same_thread=False)
26+
self.con = sqlite3.connect(os.getcwd() + "data.db", check_same_thread=False)
2627
self.cur = self.con.cursor()
2728
self.setup()
2829

0 commit comments

Comments
 (0)