-
Notifications
You must be signed in to change notification settings - Fork 0
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 53b53f6
Showing
14 changed files
with
694 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,4 @@ | ||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= | ||
POSTGRES_HOST= | ||
POSTGRES_DB=giganoto |
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,3 @@ | ||
.vscode/ | ||
.env | ||
*.pyc |
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,25 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
fastapi = "*" | ||
sqlalchemy = "*" | ||
uvicorn = "*" | ||
psycopg2 = "*" | ||
python-multipart = "*" | ||
requests = "*" | ||
flake8 = "*" | ||
bcrypt = "*" | ||
pydantic = {extras = ["email"], version = "*"} | ||
pytest = "*" | ||
sqlalchemy-utils = "*" | ||
python-dotenv = "*" | ||
pyjwt = "*" | ||
cerberus = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.9" |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
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,20 @@ | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from routers.api import router | ||
from db.main import engine | ||
from db.models import Base | ||
|
||
Base.metadata.create_all(bind=engine) | ||
app = FastAPI( | ||
title='ReaBar' | ||
) | ||
|
||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_credentials=True, | ||
allow_origins=['*'], | ||
allow_methods=['*'], | ||
allow_headers=['*'], | ||
) | ||
|
||
app.include_router(router) |
Empty file.
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,23 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker, Session | ||
from typing import Any | ||
import os | ||
|
||
DATABASE = 'postgresql' | ||
USER = os.environ.get('POSTGRES_USER') | ||
PASSWORD = os.environ.get('POSTGRES_PASSWORD') | ||
HOST = os.environ.get('POSTGRES_HOST') | ||
DB_NAME = os.environ.get('POSTGRES_DB') | ||
|
||
DATABASE_URL = "{}://{}:{}@{}/{}".format(DATABASE, USER, PASSWORD, HOST, DB_NAME) | ||
|
||
engine = create_engine(DATABASE_URL) | ||
|
||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
def get_db() -> Session: | ||
db = SessionLocal() | ||
try: | ||
yield db | ||
finally: | ||
db.close() |
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,16 @@ | ||
import datetime | ||
from typing import Any | ||
from sqlalchemy import Boolean, Column, DateTime, func | ||
from sqlalchemy.ext.declarative import as_declarative | ||
from sqlalchemy.sql.schema import ForeignKey | ||
from sqlalchemy.sql.sqltypes import String, Integer | ||
from sqlalchemy.orm import relationship | ||
from uuid import uuid4 | ||
|
||
@as_declarative() | ||
class Base: | ||
id: Any | ||
__name__: Any | ||
|
||
def generate_uuid(): | ||
return str(uuid4()) |
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,51 @@ | ||
version: '3' | ||
services: | ||
db: | ||
container_name: giganoto-db | ||
image: postgres:12 | ||
volumes: | ||
- dbdata:/var/lib/postgresql/data/ | ||
env_file: | ||
- .env | ||
|
||
server: | ||
container_name: giganoto-api | ||
build: | ||
context: . | ||
dockerfile: dockerfile_fastapi | ||
network: host | ||
volumes: | ||
- .:/opt | ||
env_file: | ||
- .env | ||
ports: | ||
- '7000:8000' | ||
depends_on: | ||
- db | ||
|
||
bot: | ||
container_name: giganoto-bot | ||
build: | ||
context: . | ||
dockerfile: dockerfile_linebot | ||
network: host | ||
volumes: | ||
- .:/opt | ||
env_file: | ||
- .env | ||
ports: | ||
- '7070:8000' | ||
depends_on: | ||
- db | ||
|
||
adminer: | ||
container_name: giganoto-adminer | ||
image: adminer:4.7.5 | ||
restart: always | ||
ports: | ||
- 7080:8080 | ||
depends_on: | ||
- db | ||
|
||
volumes: | ||
dbdata: null |
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,13 @@ | ||
FROM python:3.9.5-slim | ||
|
||
RUN mkdir -p /opt | ||
COPY . /opt/ | ||
WORKDIR /opt | ||
|
||
RUN apt update | ||
RUN apt install -y libpq-dev build-essential | ||
RUN pip install pipenv | ||
RUN pipenv install | ||
|
||
ENTRYPOINT [] | ||
CMD pipenv run uvicorn api:app --host 0.0.0.0 --reload |
Empty file.
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,3 @@ | ||
from fastapi import APIRouter | ||
|
||
router = APIRouter() |
Empty file.