Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kamikaze committed Jan 21, 2022
0 parents commit 2c3c854
Show file tree
Hide file tree
Showing 39 changed files with 2,080 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# .coveragerc to control coverage.py
[run]
branch = True
source = fastapi_project_template
# omit = bad_file.py

[paths]
source =
src/
*/site-packages/

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Temporary and binary files
*~
*.py[cod]
*.so
*.cfg
!.isort.cfg
!setup.cfg
*.orig
*.log
*.pot
__pycache__/*
.cache/*
.*.swp
*/.ipynb_checkpoints/*
.DS_Store

# Project files
.ropeproject
.project
.pydevproject
.settings
.idea
tags

# Package files
*.egg
*.eggs/
.installed.cfg
*.egg-info

# Unittest and coverage
htmlcov/*
.coverage
.tox
junit.xml
coverage.xml
.pytest_cache/

# Build and docs folder/files
build/*
dist/*
sdist/*
docs/api/*
docs/_rst/*
docs/_build/*
cover/*
MANIFEST

# Per-project virtualenvs
.venv*/

.env
5 changes: 5 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
============
Contributors
============

* Oleg Korsak <[email protected]>
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=========
Changelog
=========

Version 0.1
===========

- Initial commit
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM python:3.10-slim as build-image

WORKDIR /usr/local/bin/deployment

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y curl ca-certificates gnupg
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get install -y gcc g++ make postgresql-server-dev-all libpq-dev libffi-dev git cargo

COPY ./ /tmp/build
COPY src/fastapi_project_template/db/migrations ./migrations/
COPY src/fastapi_project_template/db/alembic.ini ./alembic.ini

RUN (cd /tmp/build \
&& python3 -m venv py3env-dev \
&& . py3env-dev/bin/activate \
&& python3 -m pip install -U -r requirements_dev.txt \
&& python3 setup.py bdist_wheel)


RUN export APP_HOME=/usr/local/bin/deployment \
&& (cd $APP_HOME \
&& python3 -m venv py3env \
&& . py3env/bin/activate \
&& python3 -m pip install -U pip \
&& python3 -m pip install -U setuptools \
&& python3 -m pip install -U wheel \
&& python3 -m pip install -U fastapi_project_template --find-links=/tmp/build/dist)


FROM python:3.10-slim

ENV PYTHONPATH=/usr/local/bin/deployment

RUN mkdir -p /usr/local/bin/deployment \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y libpq-dev

WORKDIR /usr/local/bin/deployment

COPY --from=build-image /usr/local/bin/deployment/ ./

RUN groupadd -r appgroup \
&& useradd -r -G appgroup -d /home/appuser appuser \
&& install -d -o appuser -g appgroup /usr/local/bin/deployment/logs

USER appuser

EXPOSE 8080


CMD ["/usr/local/bin/deployment/py3env/bin/python3", "-m", "uvicorn", "fastapi_project_template.api.http:app", \
"--host", "0.0.0.0", "--port", "8080"]
Loading

0 comments on commit 2c3c854

Please sign in to comment.