commit a3950a90bdc0c1d3f1e81151c9a1445b520e56cb Author: Pvalenzu Date: Wed Mar 22 22:16:59 2023 -0300 First commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..aec8570 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +dockerfile +docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c335fc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.10.10-alpine3.17 +WORKDIR /app/ +COPY . /app/ +RUN pip3 install -r requirements.txt +CMD ["uvicorn","sql_app.main:app","--host","0.0.0.0","--reload"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..4836265 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Proyecto de estudio para desarrollar en FastAPI + + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/db_conection/__init__.py b/db_conection/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/db_conection/database.py b/db_conection/database.py new file mode 100644 index 0000000..48f3a97 --- /dev/null +++ b/db_conection/database.py @@ -0,0 +1,11 @@ +from sqlalchemy import create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import sessionmaker +import os +SQLALCHEMY_DATABASE_URL = os.getenv('DB_URL') +# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db" + +engine = create_engine(SQLALCHEMY_DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) + +Base = declarative_base() diff --git a/dependencies.py b/dependencies.py new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..e5e7b97 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,33 @@ +version: '3.8' +services: + db: + networks: + - postgres + image: postgres:15.2-alpine3.17 + environment: + - POSTGRES_USER=capycode + - POSTGRES_DB=estudio + - POSTGRES_PASSWORD=capycode123 + expose: + - "5432" + api: + networks: + - postgres + image: FastApi_estudio:0.0.1 + ports: + - "8000:8000" + environment: + - DB_URL=postgresql://capycode:capycode123@db:5432/estudio + depends_on: + - db + pgadmin: + networks: + - postgres + image: dpage/pgadmin4 + environment: + - PGADMIN_DEFAULT_EMAIL=CapycodeUSM@gmail.com + - PGADMIN_DEFAULT_PASSWORD=capycode123 + ports: + - "3000:80" +networks: + postgres: diff --git a/internal/__init__.py b/internal/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..daf30f2 --- /dev/null +++ b/main.py @@ -0,0 +1,2 @@ +from fastapi import FastAPI + diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..04ac195 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +fastapi>=0.95.0 +uvicorn>=0.21.1 +sqlalchemy>=1.4.47 +psycopg2-binary diff --git a/routers/__init__.py b/routers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/schemas/__init__.py b/schemas/__init__.py new file mode 100644 index 0000000..e69de29