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

Commit d78c319

Browse files
authored
Nickatnight/replace mongo with postgres (#6)
* feat: replace mongo with protgres...add poetry * chore: remove poetry temporarily..small clean up; feat: add release GHA * devops: edit GHA trigger * chore: update GHA os version * config: update packages * config: update default env vars
1 parent 009b0c9 commit d78c319

File tree

21 files changed

+129
-126
lines changed

21 files changed

+129
-126
lines changed

.env_example

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ ENV=dev
22
PROJECT_NAME=fastapi_backend_base
33
VERSION=v1
44

5-
MONGODB_USER=fastapibackendbase
6-
MONGODB_PASS=fastapibackendbase1234
7-
MONGODB_HOST=mongodb
8-
MONGODB_DATABASE=fastapibackendbase
9-
MONGODB_PORT=27017
5+
POSTGRES_USER=fastapibackendbase
6+
POSTGRES_PASSWORD=fastapibackendbase0987
7+
POSTGRES_DB=fastapibackendbase
8+
POSTGRES_HOST=db
9+
POSTGRES_PORT=5432
1010

11-
MONGO_INITDB_ROOT_USERNAME=admin
12-
MONGO_INITDB_ROOT_PASSWORD=admin1234
13-
MONGO_INITDB_DATABASE=fastapibackendbase
11+
ENCRYPT_KEY=
12+
SECRET_KEY=
1413

1514
NGINX_HOST=localhost
1615
UPSTREAMS=/:backend:8000

.github/workflows/main.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: lint and test
22

33
on:
44
push:
5+
tags:
6+
- '*'
7+
pull_request:
58
branches:
69
- master
710
- develop
@@ -30,5 +33,23 @@ jobs:
3033
- name: run black
3134
working-directory: ./backend
3235
run: |
33-
pip install black==21.5b1
36+
pip install black==22.6.0
3437
black --check .
38+
39+
create-release:
40+
needs: [linter, black]
41+
runs-on: ubuntu-20.04
42+
steps:
43+
- name: checkout
44+
uses: actions/checkout@v2
45+
with:
46+
fetch-depth: 0 # need this for all history for all branches and tags
47+
- name: Create Release
48+
id: create_release
49+
uses: nickatnight/releases-action@v3
50+
if: startsWith(github.ref, 'refs/tags/')
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
outputs:
55+
ReleaseTag: ${{ steps.create_release.outputs.release_tag }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
13
.env
24

35
__pycache__

backend/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
FROM alpine:3.11
1+
FROM alpine:3.14
22

33
LABEL maintainer Nick <[email protected]>
44

55
ARG env
66
ENV REQUIREMENTS_FILE ${env:-dev}.txt
77
ENV PYTHONPATH "${PYTHONPATH}:/code"
88

9+
# Install base packages
910
RUN apk add --no-cache \
1011
bash \
1112
python3-dev \
1213
py3-pip \
14+
postgresql-dev \
1315
gcc \
16+
libffi-dev \
17+
g++ \
1418
musl-dev &&\
1519
pip3 install --upgrade pip &&\
1620
rm -rf /tmp/*
1721

22+
1823
ADD /requirements/base.txt /requirements/$REQUIREMENTS_FILE /tmp/
1924
RUN pip3 install --no-cache-dir -r /tmp/$REQUIREMENTS_FILE
2025

backend/logconfig.yml

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

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ exclude = '''
1010
| \.venv
1111
| _build
1212
)/
13-
'''
13+
'''

backend/requirements/base.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# api
2-
fastapi==0.65.1
3-
uvicorn==0.13.4
2+
fastapi==0.81.0
3+
uvicorn==0.18.3
44

55
# database
6-
SQLAlchemy==1.3.24
7-
pydantic==1.8.2
8-
motor==2.4.0
6+
asyncpg==0.26.0
7+
sqlmodel==0.0.7
8+
psycopg2-binary==2.9.3
99

1010
# utils
11-
PyYAML==5.4.1
11+
aioredis==2.0.1
1212
fastapi-limiter==0.1.4

backend/requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-r base.txt
22

33
pytest==6.2.3
4-
black==21.5b1
4+
black==22.6.0
55
flake8==3.9.2
66
pytest-cov==2.12.0

backend/src/api/v1/health.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from fastapi import APIRouter, Depends
2-
from fastapi_limiter.depends import RateLimiter
1+
from fastapi import APIRouter
2+
3+
# from fastapi_limiter.depends import RateLimiter
34

45

56
router = APIRouter()
67

78

8-
@router.get("/ping", tags=["health"], dependencies=[Depends(RateLimiter(times=2, seconds=5))])
9+
@router.get("/ping", tags=["health"])
910
async def pong():
1011
# some async operation could happen here
1112
# example: `data = await get_all_datas()`

backend/src/core/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)