generated from kamikaze/python3-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2c3c854
Showing
39 changed files
with
2,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__.: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
============ | ||
Contributors | ||
============ | ||
|
||
* Oleg Korsak <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
========= | ||
Changelog | ||
========= | ||
|
||
Version 0.1 | ||
=========== | ||
|
||
- Initial commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
Oops, something went wrong.