Updated api
This commit is contained in:
@@ -6,6 +6,8 @@ ENV PYTHONFAULTHANDLER=1
|
||||
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
ENV MODE="DEVELOPMENT"
|
||||
|
||||
RUN mkdir -p /app
|
||||
|
||||
COPY requirements.txt /app
|
||||
|
||||
23
Dockerfile.prod
Normal file
23
Dockerfile.prod
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM python:3.12-bullseye
|
||||
|
||||
ENV COMPANYID=1
|
||||
|
||||
ENV PYTHONFAULTHANDLER=1
|
||||
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
ENV MODE="PRODUCTION"
|
||||
|
||||
RUN mkdir -p /app
|
||||
|
||||
COPY requirements.txt /app
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip3 install setuptools
|
||||
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
EXPOSE 8003
|
||||
|
||||
COPY . /app
|
||||
@@ -3,13 +3,19 @@ from sqlalchemy.engine import URL
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
from config import load_config
|
||||
|
||||
|
||||
ApplicationConfig = load_config()
|
||||
|
||||
|
||||
url = URL.create(
|
||||
drivername="postgresql",
|
||||
username="postgres",
|
||||
password="password",
|
||||
host="192.168.1.204",
|
||||
database="eamco",
|
||||
port=5432
|
||||
username=ApplicationConfig.POSTGRES_USERNAME,
|
||||
password=ApplicationConfig.POSTGRES_PW,
|
||||
host=ApplicationConfig.POSTGRES_SERVER,
|
||||
database=ApplicationConfig.POSTGRES_DBNAME00,
|
||||
port=ApplicationConfig.POSTGRES_PORT
|
||||
)
|
||||
|
||||
engine = create_engine(url)
|
||||
|
||||
20
config.py
Normal file
20
config.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
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
|
||||
return ApplicationConfig
|
||||
else:
|
||||
pass
|
||||
|
||||
except ImportError:
|
||||
from settings_local import ApplicationConfig
|
||||
return ApplicationConfig
|
||||
19
settings_local.py
Normal file
19
settings_local.py
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
class ApplicationConfig:
|
||||
"""
|
||||
Basic Configuration for a generic User
|
||||
"""
|
||||
CURRENT_SETTINGS = 'LOCAL'
|
||||
# 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
|
||||
)
|
||||
|
||||
17
settings_prod.py
Normal file
17
settings_prod.py
Normal file
@@ -0,0 +1,17 @@
|
||||
class ApplicationConfig:
|
||||
"""
|
||||
Basic Configuration for a generic User
|
||||
"""
|
||||
CURRENT_SETTINGS = 'LOCAL'
|
||||
# databases info
|
||||
POSTGRES_USERNAME = 'postgres'
|
||||
POSTGRES_PW = 'password'
|
||||
POSTGRES_SERVER = '192.168.1.204'
|
||||
POSTGRES_PORT = '5432'
|
||||
POSTGRES_DBNAME00 = 'auburnoil'
|
||||
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://{}:{}@{}/{}".format(POSTGRES_USERNAME,
|
||||
POSTGRES_PW,
|
||||
POSTGRES_SERVER,
|
||||
POSTGRES_DBNAME00
|
||||
)
|
||||
SQLALCHEMY_BINDS = {'eamco': SQLALCHEMY_DATABASE_URI}
|
||||
Reference in New Issue
Block a user