From e9d589294cd2dca0d52739dbbc011fd67f6aecb4 Mon Sep 17 00:00:00 2001 From: adrianmf94 Date: Tue, 11 Jun 2024 02:14:05 +0200 Subject: [PATCH] task: WIP | Fixing .env issue --- Dockerfile | 5 ++++- backend/app/upload.py | 12 +++++++++++- backend/pyproject.toml | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7289dedb..b678e809 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN yarn --network-timeout 600000 --frozen-lockfile COPY ./frontend ./ -RUN rm -rf .env +# RUN rm -rf .env RUN yarn build @@ -28,6 +28,9 @@ RUN wget -O golang-migrate.deb https://github.com/golang-migrate/migrate/release # Install Poetry RUN pip install poetry +# Copy th environment file +COPY .env ./backend/app/.env + # Set the working directory WORKDIR /backend diff --git a/backend/app/upload.py b/backend/app/upload.py index e2dac7e9..c4a6502f 100644 --- a/backend/app/upload.py +++ b/backend/app/upload.py @@ -28,6 +28,13 @@ from app.ingest import ingest_blob from app.parsing import MIMETYPE_BASED_PARSER +from dotenv import load_dotenv +import os + +#dotenv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env')) +dotenv_path = os.path.join(os.path.dirname(__file__), '.env') +load_dotenv(dotenv_path) + def _guess_mimetype(file_name: str, file_bytes: bytes) -> str: """Guess the mime-type of a file based on its name or bytes.""" @@ -146,7 +153,7 @@ def invoke(self, blob: Blob, config: Optional[RunnableConfig] = None) -> List[st PG_CONNECTION_STRING = PGVector.connection_string_from_db_params( driver="psycopg2", - host=os.environ["POSTGRES_HOST"], + host="postgres",#os.environ["POSTGRES_HOST"], port=int(os.environ["POSTGRES_PORT"]), database=os.environ["POSTGRES_DB"], user=os.environ["POSTGRES_USER"], @@ -170,3 +177,6 @@ def invoke(self, blob: Blob, config: Optional[RunnableConfig] = None) -> List[st name="Thread ID", ), ) + +if __name__ == "__main__": + print("dotenv_path: ", dotenv_path) \ No newline at end of file diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 89c76dd7..c178320a 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -47,6 +47,7 @@ python-json-logger = "^2.0.7" pulumi = "^3.117.0" pulumi-aws = "^6.37.1" pulumi-docker = "^4.5.4" +python-dotenv = "^1.0.1" [tool.poetry.group.dev.dependencies] uvicorn = "^0.23.2"