mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add poetry to project
This commit is contained in:
parent
7b079f84c1
commit
68eca7c0f6
28
.github/workflows/build-and-test.yml
vendored
28
.github/workflows/build-and-test.yml
vendored
@ -1,8 +1,9 @@
|
|||||||
|
name: Continuous Disaster...
|
||||||
name: Unit Tests
|
on:
|
||||||
|
pull_request:
|
||||||
on: [pull_request]
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -26,13 +27,22 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Create database schema
|
- name: Create database schema
|
||||||
run: PGPASSWORD=secret psql -h 127.0.0.1 -d testdb -U user -c "CREATE SCHEMA shakespeare; CREATE SCHEMA happy_hog;"
|
run: PGPASSWORD=secret psql -h 127.0.0.1 -d testdb -U user -c "CREATE SCHEMA shakespeare; CREATE SCHEMA happy_hog;"
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install required libs
|
- name: Install Poetry
|
||||||
run: pip install -r requirements.txt
|
uses: snok/install-poetry@v1
|
||||||
|
- name: Load cached venv
|
||||||
|
id: cached-poetry-dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .venv
|
||||||
|
key: venv-${{ runner.os }}-3.10-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
- name: Install dependencies
|
||||||
|
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||||
|
run: poetry install --no-interaction --no-root
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest
|
run: pytest
|
||||||
env:
|
env:
|
||||||
|
51
Dockerfile
51
Dockerfile
@ -1,20 +1,41 @@
|
|||||||
# Pull base image
|
FROM python:3.10-slim AS base
|
||||||
FROM python:3.10-slim-buster as builder
|
RUN apt-get update \
|
||||||
|
&& apt-get upgrade -y \
|
||||||
|
&& apt-get install -y --no-install-recommends curl git build-essential \
|
||||||
|
&& apt-get autoremove -y
|
||||||
|
ENV POETRY_HOME="/opt/poetry"
|
||||||
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||||
|
|
||||||
# Set environment variables
|
FROM base AS install
|
||||||
COPY requirements.txt requirements.txt
|
WORKDIR /home/code
|
||||||
|
|
||||||
# Install pipenv
|
# allow controlling the poetry installation of dependencies via external args
|
||||||
RUN set -ex && pip install --upgrade pip
|
ARG INSTALL_ARGS="--no-root --no-dev"
|
||||||
|
ENV POETRY_HOME="/opt/poetry"
|
||||||
|
ENV PATH="$POETRY_HOME/bin:$PATH"
|
||||||
|
COPY pyproject.toml poetry.lock ./
|
||||||
|
|
||||||
# Install dependencies
|
# install without virtualenv, since we are inside a container
|
||||||
RUN set -ex && pip install -r requirements.txt
|
RUN poetry config virtualenvs.create false \
|
||||||
|
&& poetry install $INSTALL_ARGS
|
||||||
|
|
||||||
FROM builder as final
|
# cleanup
|
||||||
WORKDIR /code
|
RUN curl -sSL https://install.python-poetry.org | python3 - --uninstall
|
||||||
COPY app/ /code/
|
RUN apt-get purge -y curl git build-essential \
|
||||||
COPY ./tests/ /code/
|
&& apt-get clean -y \
|
||||||
COPY .env /code/
|
&& rm -rf /root/.cache \
|
||||||
|
&& rm -rf /var/apt/lists/* \
|
||||||
|
&& rm -rf /var/cache/apt/*
|
||||||
|
|
||||||
|
FROM install as app-image
|
||||||
|
|
||||||
|
COPY tests tests
|
||||||
|
COPY app app
|
||||||
|
COPY alembic alembic
|
||||||
|
COPY .env alembic.ini ./
|
||||||
|
|
||||||
|
# create a non-root user and switch to it, for security.
|
||||||
|
RUN addgroup --system --gid 1001 "app-user"
|
||||||
|
RUN adduser --system --uid 1001 "app-user"
|
||||||
|
USER "app-user"
|
||||||
|
|
||||||
RUN set -ex && bash -c "eval $(grep 'PYTHONDONTWRITEBYTECODE' .env)"
|
|
||||||
RUN set -ex && bash -c "eval $(grep 'PYTHONUNBUFFERED' .env)"
|
|
||||||
|
38
Pipfile
38
Pipfile
@ -1,38 +0,0 @@
|
|||||||
[[source]]
|
|
||||||
url = "https://pypi.org/simple"
|
|
||||||
verify_ssl = true
|
|
||||||
name = "pypi"
|
|
||||||
|
|
||||||
[packages]
|
|
||||||
fastapi = "*"
|
|
||||||
pydantic = "*"
|
|
||||||
httptools = "*"
|
|
||||||
httpx = "==0.23.0"
|
|
||||||
requests = "==2.28.1"
|
|
||||||
uvicorn = "*"
|
|
||||||
uvloop = "*"
|
|
||||||
asyncpg = "*"
|
|
||||||
sqlalchemy = {extras = ["asyncio"], version = "*"}
|
|
||||||
alembic = "*"
|
|
||||||
eventlet = "*"
|
|
||||||
rich = "*"
|
|
||||||
|
|
||||||
[dev-packages]
|
|
||||||
devtools = {extras = ["pygments"], version = "*"}
|
|
||||||
isort = "*"
|
|
||||||
mypy = "*"
|
|
||||||
flake8 = "*"
|
|
||||||
black = "*"
|
|
||||||
safety = "*"
|
|
||||||
autoflake = "*"
|
|
||||||
pyupgrade = "*"
|
|
||||||
ipython = "*"
|
|
||||||
pylint = "*"
|
|
||||||
pytest-cov = "*"
|
|
||||||
pytest-asyncio = "*"
|
|
||||||
|
|
||||||
[requires]
|
|
||||||
python_version = "3.10"
|
|
||||||
|
|
||||||
[pipenv]
|
|
||||||
allow_prereleases = true
|
|
1222
Pipfile.lock
generated
1222
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@ -50,4 +50,5 @@ Hope you enjoy it.
|
|||||||
|
|
||||||
### Change Log
|
### Change Log
|
||||||
- 4 JUN 2022 alembic migrations added to project
|
- 4 JUN 2022 alembic migrations added to project
|
||||||
- 6 JUN 2022 added initial dataset for shakespeare models
|
- 6 JUN 2022 added initial dataset for shakespeare models
|
||||||
|
- 3 OCT 2022 poetry added to project
|
2013
poetry.lock
generated
Normal file
2013
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
36
pyproject.toml
Normal file
36
pyproject.toml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "fastapi-sqlalchemy-asyncpg"
|
||||||
|
version = "0.0.1"
|
||||||
|
description = ""
|
||||||
|
authors = ["Jakub Miazek <the@grillazz.com>"]
|
||||||
|
packages = []
|
||||||
|
license = "MIT"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.10"
|
||||||
|
alembic = "*"
|
||||||
|
asyncpg = "*"
|
||||||
|
httpx = "*"
|
||||||
|
pydantic = "*"
|
||||||
|
sqlalchemy = "*"
|
||||||
|
fastapi = "*"
|
||||||
|
uvicorn = { extras = ["standard"], version = "*" }
|
||||||
|
uvloop = "*"
|
||||||
|
httptools = "*"
|
||||||
|
rich = "*"
|
||||||
|
devtools = {extras = ["pygments"], version = "*"}
|
||||||
|
isort = "*"
|
||||||
|
mypy = "*"
|
||||||
|
flake8 = "*"
|
||||||
|
black = "*"
|
||||||
|
safety = "*"
|
||||||
|
autoflake = "*"
|
||||||
|
pyupgrade = "*"
|
||||||
|
ipython = "*"
|
||||||
|
pylint = "*"
|
||||||
|
pytest-cov = "*"
|
||||||
|
pytest-asyncio = "*"
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
@ -1,84 +0,0 @@
|
|||||||
alembic==1.8.1
|
|
||||||
anyio==3.6.1
|
|
||||||
appnope==0.1.3
|
|
||||||
asgiref==3.5.2
|
|
||||||
astroid==2.6.6
|
|
||||||
asttokens==2.0.5
|
|
||||||
asyncpg==0.26.0
|
|
||||||
attrs==21.4.0
|
|
||||||
autoflake==1.4
|
|
||||||
backcall==0.2.0
|
|
||||||
black==22.3.0
|
|
||||||
certifi==2022.6.15.1
|
|
||||||
charset-normalizer==2.1.1
|
|
||||||
click==8.1.3
|
|
||||||
commonmark==0.9.1
|
|
||||||
coverage==6.4
|
|
||||||
decorator==5.1.1
|
|
||||||
devtools==0.8.0
|
|
||||||
dnspython==2.2.1
|
|
||||||
dparse==0.5.2
|
|
||||||
eventlet==0.33.1
|
|
||||||
executing==0.8.3
|
|
||||||
fastapi==0.83.0
|
|
||||||
flake8==4.0.1
|
|
||||||
greenlet==2.0.0a2
|
|
||||||
h11==0.12.0
|
|
||||||
httpcore==0.15.0
|
|
||||||
httptools==0.4.0
|
|
||||||
httpx==0.23.0
|
|
||||||
idna==3.3
|
|
||||||
iniconfig==1.1.1
|
|
||||||
ipython==8.3.0
|
|
||||||
isort==5.10.1
|
|
||||||
jedi==0.18.1
|
|
||||||
lazy-object-proxy==1.7.1
|
|
||||||
Mako==1.2.2
|
|
||||||
MarkupSafe==2.1.1
|
|
||||||
matplotlib-inline==0.1.3
|
|
||||||
mccabe==0.6.1
|
|
||||||
mypy==0.960
|
|
||||||
mypy-extensions==0.4.3
|
|
||||||
packaging==21.3
|
|
||||||
parso==0.8.3
|
|
||||||
pathspec==0.9.0
|
|
||||||
pexpect==4.8.0
|
|
||||||
pickleshare==0.7.5
|
|
||||||
platformdirs==2.5.2
|
|
||||||
pluggy==1.0.0
|
|
||||||
prompt-toolkit==3.0.29
|
|
||||||
ptyprocess==0.7.0
|
|
||||||
pure-eval==0.2.2
|
|
||||||
py==1.11.0
|
|
||||||
pycodestyle==2.8.0
|
|
||||||
pydantic==1.10.2
|
|
||||||
pyflakes==2.4.0
|
|
||||||
Pygments==2.13.0
|
|
||||||
pylint==3.0.0a4
|
|
||||||
pyparsing==3.0.9
|
|
||||||
pytest==7.1.2
|
|
||||||
pytest-asyncio==0.18.3
|
|
||||||
pytest-cov==3.0.0
|
|
||||||
pyupgrade==2.32.1
|
|
||||||
PyYAML==6.0
|
|
||||||
requests==2.28.1
|
|
||||||
rfc3986==1.5.0
|
|
||||||
rich==12.5.1
|
|
||||||
ruamel.yaml==0.17.21
|
|
||||||
ruamel.yaml.clib==0.2.6
|
|
||||||
safety==2.0b1
|
|
||||||
six==1.16.0
|
|
||||||
sniffio==1.3.0
|
|
||||||
SQLAlchemy==1.4.41
|
|
||||||
stack-data==0.2.0
|
|
||||||
starlette==0.19.1
|
|
||||||
tokenize-rt==4.2.1
|
|
||||||
toml==0.10.2
|
|
||||||
tomli==2.0.1
|
|
||||||
traitlets==5.2.1.post0
|
|
||||||
typing_extensions==4.3.0
|
|
||||||
urllib3==1.26.12
|
|
||||||
uvicorn==0.18.3
|
|
||||||
uvloop==0.16.0
|
|
||||||
wcwidth==0.2.5
|
|
||||||
wrapt==1.12.1
|
|
Loading…
x
Reference in New Issue
Block a user