diff --git a/Dockerfile b/Dockerfile.dev similarity index 100% rename from Dockerfile rename to Dockerfile.dev 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/config.py b/config.py index 7078235..e236898 100644 --- a/config.py +++ b/config.py @@ -5,13 +5,17 @@ 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': - - from settings_local import ApplicationConfig + + elif mode == 'LOCAL': + from settings_dev 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 9f7bc52..3b5075b 100644 --- a/main.py +++ b/main.py @@ -12,23 +12,9 @@ app = FastAPI() app.include_router(delivery.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", - -] - app.add_middleware( CORSMiddleware, - allow_origins=origins, + allow_origins=ApplicationConfig.origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/settings_dev.py b/settings_dev.py new file mode 100644 index 0000000..53befd0 --- /dev/null +++ b/settings_dev.py @@ -0,0 +1,29 @@ + + +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..f43c489 100644 --- a/settings_local.py +++ b/settings_local.py @@ -10,10 +10,19 @@ 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..fcda382 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