logeswari commited on
Commit
b3bbdb9
·
1 Parent(s): 3fe0596
Files changed (2) hide show
  1. Dockerfile +9 -7
  2. utils/logger.py +3 -1
Dockerfile CHANGED
@@ -1,18 +1,20 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Copy all the files into the container
8
  COPY . /app
9
 
10
- # Install required Python packages
11
- RUN pip install --no-cache-dir fastapi uvicorn pandas pydantic
12
 
13
- # Expose the port FastAPI runs on
 
 
 
14
  EXPOSE 7860
15
 
16
  # Command to run the application
17
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
18
-
 
1
+ # Use a base image
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory
5
  WORKDIR /app
6
 
7
+ # Copy project files
8
  COPY . /app
9
 
10
+ # Ensure the logs directory exists and is writable
11
+ RUN mkdir -p logs && chmod -R 777 logs
12
 
13
+ # Install dependencies
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
16
+ # Expose the application port
17
  EXPOSE 7860
18
 
19
  # Command to run the application
20
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
utils/logger.py CHANGED
@@ -2,7 +2,9 @@ import logging
2
  import os
3
 
4
  # Ensure the 'logs' directory exists
5
- log_dir = "logs"
 
 
6
  os.makedirs(log_dir, exist_ok=True)
7
 
8
  # Configure logging
 
2
  import os
3
 
4
  # Ensure the 'logs' directory exists
5
+ log_dir = "logs" # Use a relative path to avoid permission issues
6
+ log_file = f"{log_dir}/app.log"
7
+
8
  os.makedirs(log_dir, exist_ok=True)
9
 
10
  # Configure logging