Updated code for Flask API container

This commit is contained in:
Marcin-Ramotowski 2025-03-14 22:06:20 +00:00
parent a9775f4fa5
commit c63c785686
4 changed files with 14 additions and 8 deletions

View File

@ -1,5 +1,5 @@
FROM python:3.11.7-slim-bookworm FROM python:3.11.7-slim-bookworm
WORKDIR /app WORKDIR /app
COPY src . COPY api .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
CMD python3 app.py CMD python3 app.py

View File

@ -9,7 +9,7 @@ import os
if __name__ == "__main__": if __name__ == "__main__":
load_dotenv() load_dotenv()
app = Flask(__name__) app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URI') app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['JWT_SECRET_KEY'] = 'changeme' app.config['JWT_SECRET_KEY'] = 'changeme'
app.register_blueprint(user_bp) app.register_blueprint(user_bp)

View File

@ -1,11 +1,13 @@
blinker==1.7.0 blinker==1.7.0
click==8.1.7 click==8.1.7
Flask==3.0.0 Flask==3.0.0
Flask-JWT-Extended==4.7.1
Flask-SQLAlchemy==3.1.1 Flask-SQLAlchemy==3.1.1
greenlet==3.0.1 greenlet==3.0.1
itsdangerous==2.1.2 itsdangerous==2.1.2
Jinja2==3.1.2 Jinja2==3.1.2
MarkupSafe==2.1.3 MarkupSafe==2.1.3
mysql-connector-python==9.2.0
python-dotenv==1.0.0 python-dotenv==1.0.0
SQLAlchemy==2.0.23 SQLAlchemy==2.0.23
typing_extensions==4.8.0 typing_extensions==4.8.0

View File

@ -1,13 +1,17 @@
version: '3.7'
services: services:
web: api:
container_name: todo-api container_name: todo-api
hostname: todo-api hostname: todo-api
build: . build: .
env_file: env_file:
- src/.env - api/.env
ports: ports:
- "5000:5000" - "5000:5000"
volumes: #volumes:
- ./src/test.db:/app/test.db #- ./api/test.db:/app/test.db
db:
container_name: db
hostname: db
image: mysql:latest
env_file:
- db/.env