diff --git a/Dockerfile b/Dockerfile.dev similarity index 72% rename from Dockerfile rename to Dockerfile.dev index 3949ba3..d501bc1 100644 --- a/Dockerfile +++ b/Dockerfile.dev @@ -12,12 +12,6 @@ COPY requirements.txt /app WORKDIR /app -RUN pip3 install setuptools - -RUN pip3 install fastapi - -RUN pip3 install sqlalchemy - RUN pip3 install -r requirements.txt EXPOSE 8000 diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 0000000..386dd58 --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,19 @@ +FROM python:3.12-bullseye + +ENV PYTHONFAULTHANDLER=1 + +ENV PYTHONUNBUFFERED=1 + +ENV MODE="LOCAL" + +RUN mkdir -p /app + +COPY requirements.txt /app + +WORKDIR /app + +RUN pip3 install -r requirements.txt + +EXPOSE 8000 + +COPY . /app \ No newline at end of file diff --git a/Dockerfile.prod b/Dockerfile.prod index 95600d8..265b50b 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,7 +1,5 @@ FROM python:3.12-bullseye -ENV TZ="America/New_York" - ENV PYTHONFAULTHANDLER=1 ENV PYTHONUNBUFFERED=1 @@ -14,10 +12,8 @@ COPY requirements.txt /app WORKDIR /app -RUN pip3 install setuptools - RUN pip3 install -r requirements.txt -EXPOSE 8001 +EXPOSE 8000 COPY . /app \ No newline at end of file diff --git a/app/models/cards.py b/app/models/cards.py index 2db8c85..16b1eb2 100644 --- a/app/models/cards.py +++ b/app/models/cards.py @@ -9,7 +9,6 @@ from database import Base class Card_Card(Base): __tablename__ = 'card_card' - __bind_key__ = 'eamco' __table_args__ = {"schema": "public"} id = Column(Integer, diff --git a/app/models/employee.py b/app/models/employee.py index 350d74c..af5c284 100644 --- a/app/models/employee.py +++ b/app/models/employee.py @@ -7,7 +7,6 @@ from database import Base class Employee_Employee(Base): __tablename__ = 'employee_employee' - __bind_key__ = 'eamco' __table_args__ = {"schema": "public"} id = Column(INTEGER, diff --git a/config.py b/config.py index 7078235..2b79c46 100644 --- a/config.py +++ b/config.py @@ -5,13 +5,16 @@ def load_config(mode=os.environ.get('MODE')): try: print(f"mode is {mode}") if mode == 'PRODUCTION': - from settings_prod import ApplicationConfig return ApplicationConfig - elif mode == 'DEVELOPMENT': + elif mode == 'LOCAL': from settings_local import ApplicationConfig return ApplicationConfig + + elif mode == 'DEVELOPMENT': + from settings_dev import ApplicationConfig + return ApplicationConfig else: pass diff --git a/main.py b/main.py index 88e9562..3abf048 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,11 @@ from fastapi import FastAPI from app.routers import main, delivery, confirm from fastapi.middleware.cors import CORSMiddleware +import os +from config import load_config + + +ApplicationConfig = load_config() app = FastAPI() @@ -10,23 +15,11 @@ app.include_router(main.router) app.include_router(delivery.router) app.include_router(confirm.router) -origins = [ - "http://localhost:9000", - "https://localhost:9513", - "http://localhost:9514", - "http://localhost:9512", - "http://localhost:9511", - "http://192.168.1.204:9000", - "http://192.168.1.204:9513", - "http://192.168.1.204:9514", - "http://192.168.1.204:9512", - "http://192.168.1.204:9511", -] - +# print(ApplicationConfig.origins) app.add_middleware( CORSMiddleware, - allow_origins=origins, + allow_origins=ApplicationConfig.origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/requirements.txt b/requirements.txt index 43bf3a5..c934fb0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ fastapi uvicorn[standard] psycopg2-binary sqlalchemy -pyowm \ No newline at end of file +pyowm +setuptools \ No newline at end of file diff --git a/settings_dev.py b/settings_dev.py new file mode 100644 index 0000000..56d4729 --- /dev/null +++ b/settings_dev.py @@ -0,0 +1,28 @@ + + +class ApplicationConfig: + """ + Basic Configuration for a generic User + """ + CURRENT_SETTINGS = 'DEVELOPMENT' + # databases info + POSTGRES_USERNAME = 'postgres' + POSTGRES_PW = 'password' + POSTGRES_SERVER = '192.168.1.204' + POSTGRES_PORT = '5432' + POSTGRES_DBNAME00 = 'eamco' + SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://{}:{}@{}/{}".format(POSTGRES_USERNAME, + POSTGRES_PW, + POSTGRES_SERVER, + POSTGRES_DBNAME00 + ) + SQLALCHEMY_BINDS = {'eamco': SQLALCHEMY_DATABASE_URI} + + origins = [ + "http://localhost:9000", + "https://localhost:9513", + "http://localhost:9514", + "http://localhost:9512", + "http://localhost:9511", + +] \ No newline at end of file diff --git a/settings_local.py b/settings_local.py index 82417a3..6adacf0 100644 --- a/settings_local.py +++ b/settings_local.py @@ -10,10 +10,20 @@ class ApplicationConfig: POSTGRES_PW = 'password' POSTGRES_SERVER = '192.168.1.204' POSTGRES_PORT = '5432' - POSTGRES_DBNAME00 = 'eamco' + POSTGRES_DBNAME00 = 'auburnoil' SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://{}:{}@{}/{}".format(POSTGRES_USERNAME, POSTGRES_PW, POSTGRES_SERVER, POSTGRES_DBNAME00 ) + SQLALCHEMY_BINDS = {'auburnoil': SQLALCHEMY_DATABASE_URI} + + + origins = [ + "http://192.168.1.204:9000", + "http://192.168.1.204:9613", + "http://192.168.1.204:9614", + "http://192.168.1.204:9612", + "http://192.168.1.204:9611", +] \ No newline at end of file diff --git a/settings_prod.py b/settings_prod.py index 269c60f..42e1f8e 100644 --- a/settings_prod.py +++ b/settings_prod.py @@ -2,7 +2,7 @@ class ApplicationConfig: """ Basic Configuration for a generic User """ - CURRENT_SETTINGS = 'LOCAL' + CURRENT_SETTINGS = 'PRODUCTION' # databases info POSTGRES_USERNAME = 'postgres' POSTGRES_PW = 'password' @@ -14,4 +14,9 @@ class ApplicationConfig: POSTGRES_SERVER, POSTGRES_DBNAME00 ) - SQLALCHEMY_BINDS = {'eamco': SQLALCHEMY_DATABASE_URI} + SQLALCHEMY_BINDS = {'auburnoil': SQLALCHEMY_DATABASE_URI} + + origins = [ + "https://oil.edwineames.com", + "https://apiauto.edwineames.com", +] \ No newline at end of file