Skip to content

Commit

Permalink
Started deploying the project on Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
iduseev committed Sep 15, 2023
1 parent e034c7a commit 9207c78
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# IDE
.vscode
.idea

# Thumbnails
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11 AS build

WORKDIR /app

COPY ./requirements.in ./

RUN python -m venv /.venv \
&& /.venv/bin/pip install -r requirements.in

FROM python:slim AS release
WORKDIR /app

EXPOSE 80
CMD ["/.venv/bin/uvicorn", "backend.endpoints:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80"]

COPY --from=build /.venv /.venv
COPY . .
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "3.8"
services:

api:
build:
context: ./
dockerfile: Dockerfile
container_name: api
mem_limit: 512m
environment:
- MONGODB_URI=mongodb://username:password@localhost:27017/db_name?authSource=admin
networks:
- fastapi_demo_project
network_mode: "host"
ports:
- "8080:80"
restart: always

mongo:
image: mongo:latest
ports:
- "27017:27017"
# environment:
# MONGO_INITDB_DATABASE: mymongodb

networks:
fastapi_demo_project:
driver: bridge
name: fastapi_demo_project

0 comments on commit 9207c78

Please sign in to comment.