Skip to content

Commit

Permalink
- docker fastapi application
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-st0rm committed Jan 20, 2023
1 parent a00ac0f commit 4a56921
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
venv
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.git
.mypy_cache
.pytest_cache
.hypothesis
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.10-slim
WORKDIR /menu_app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
COPY . .

45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3.8'

services:
web:
build:
context: .
dockerfile: Dockerfile
container_name: web_api
ports:
- "8000:8000"
environment:
CONFIG_FILE: "cfg.ini"
SQLALCHEMY_WARN_20: 0
entrypoint: >
sh -c "
python3 main.py
"
networks:
- web_main_api
restart: on-failure
depends_on:
- db

db:
image: postgres:15.1-alpine
container_name: db-pg
volumes:
- postgres_data:/var/lib/postgresql/data/
expose:
- 5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=menu_app
restart: on-failure
networks:
- web_main_api


volumes:
postgres_data:

networks:
web_main_api:
name: web_main_api
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ fastapi==0.89.1
SQLAlchemy==1.4.46
asyncpg==0.27.0
uvicorn==0.20.0
pydantic==1.10.4
pydantic==1.10.4
pytest==7.2.1
pytest_asyncio==0.20.3
httpx==0.23.3

0 comments on commit 4a56921

Please sign in to comment.