Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Commit 8e68dcf

Browse files
authored
[#8] Add Poetry for dev (#14)
* [#8] feat: add poetry for dev * [#8] fix: GHA flake8 path
1 parent 64d12a3 commit 8e68dcf

File tree

11 files changed

+66
-50
lines changed

11 files changed

+66
-50
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.DS_Store
2+
3+
.env
4+
5+
__pycache__
6+
.pytest_cache
7+
*.out
8+
9+
htmlcov/
10+
coverage.xml
11+
.coverage

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/checkout@v2
1919
- name: Start linter
2020
run: |
21-
docker run --rm -w="/code/backend" -v $(pwd):/code alpine/flake8:3.9.2 --config=pyproject.toml .
21+
docker run --rm -w="/code/backend" -v $(pwd):/code alpine/flake8:3.9.2 .
2222
2323
black:
2424
runs-on: ubuntu-20.04

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
rev: 5.0.4
2020
hooks:
2121
- id: flake8
22-
args: ["--config=./backend/pyproject.toml"]
22+
args: ["--config=./backend/.flake8"]
2323
- repo: https://github.com/PyCQA/isort
2424
rev: 5.10.1
2525
hooks:

backend/.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 100
3+
exclude = __init__.py,__pycache__,git
4+
ignore = F403,F405,W605,W503,E203,E231

backend/Dockerfile

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
FROM alpine:3.14
2-
3-
LABEL maintainer Nick <[email protected]>
1+
FROM python:3.9 as base
42

53
ARG env
6-
ENV REQUIREMENTS_FILE ${env:-dev}.txt
74
ENV PYTHONPATH "${PYTHONPATH}:/code"
85

9-
# Install base packages
10-
RUN apk add --no-cache \
11-
bash \
12-
python3-dev \
13-
py3-pip \
14-
postgresql-dev \
15-
gcc \
16-
libffi-dev \
17-
g++ \
18-
git \
19-
musl-dev &&\
20-
pip3 install --upgrade pip &&\
21-
rm -rf /tmp/*
6+
WORKDIR /tmp
7+
8+
RUN pip install poetry
9+
10+
COPY ./pyproject.toml ./poetry.lock* /tmp/
11+
12+
RUN poetry export $(test "${env:-dev}" != "prod" && echo "--with dev") \
13+
-f requirements.txt \
14+
--output requirements.txt \
15+
--without-hashes
16+
17+
FROM python:3.9
2218

19+
COPY --from=base /tmp/requirements.txt /code/requirements.txt
2320

24-
ADD /requirements/base.txt /requirements/$REQUIREMENTS_FILE /tmp/
25-
RUN pip3 install --no-cache-dir -r /tmp/$REQUIREMENTS_FILE
21+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
2622

2723
ADD . /code/
28-
WORKDIR /code/
24+
WORKDIR /code
2925

3026
EXPOSE 8000

backend/pyproject.toml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
[flake8]
2-
max-line-length = 100
3-
exclude = '__init__.py,__pycache__,git'
4-
ignore = 'F403,F405,W605,W503,E203,E231'
1+
[tool.poetry]
2+
name = "fastapi-backend-base"
3+
version = "2.4.0"
4+
description = "Base project for building fastapi backends"
5+
authors = ["nickatnight <[email protected]>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "^3.9"
9+
asyncpraw = "^7.5.0"
10+
alembic = "^1.8.1"
11+
asyncpg = "^0.26.0"
12+
fastapi = "^0.81.0"
13+
psycopg2-binary = "^2.9.3"
14+
sqlmodel = "^0.0.8"
15+
uvicorn = "^0.18.3"
16+
r-dogecoin-bot = { git = "https://github.com/nickatnight/r-dogecoin-bot", tag = "0.1.4" }
17+
18+
[tool.poetry.dev-dependencies]
19+
black = "22.6.0"
20+
flake8 = "5.0.4"
21+
isort = "5.10.1"
22+
pytest = "6.2.3"
23+
pytest-cov = "2.12.0"
524

625
[tool.isort]
726
multi_line_output = 3
@@ -14,3 +33,7 @@ sections = 'FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER'
1433
line-length = 100
1534
include = '\.pyi?$'
1635
exclude = '(\.git|\.hg|\.mypy_cache|\.tox|\.venv|_build)'
36+
37+
[build-system]
38+
requires = ["poetry-core>=1.0.0"]
39+
build-backend = "poetry.core.masonry.api"

backend/requirements/base.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

backend/requirements/dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

backend/requirements/prod.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/requirements/staging.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)