logeswari commited on
Commit
7e5c0aa
·
1 Parent(s): c5b7f46
Files changed (4) hide show
  1. Dockerfile +11 -10
  2. requirements.txt +3 -0
  3. services/population.py +1 -1
  4. utils/logger.py +1 -1
Dockerfile CHANGED
@@ -1,16 +1,17 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
 
4
- FROM python:3.9
 
5
 
6
- RUN useradd -m -u 1000 user
7
- USER user
8
- ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
- WORKDIR /app
 
11
 
12
- COPY --chown=user ./requirements.txt requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
14
 
15
- COPY --chown=user . /app
16
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
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"]
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
  fastapi[standard]
2
  pandas
 
 
 
3
 
 
1
  fastapi[standard]
2
  pandas
3
+ uvicorn
4
+ pydantic
5
+
6
 
services/population.py CHANGED
@@ -11,7 +11,7 @@ from population.utils.logger import logger
11
  from fastapi import HTTPException
12
  from population.models.schemas import ContinentPopulationResponse, CountryPopulation
13
 
14
- file_path = "D:/pandas/world_population (1).csv"
15
 
16
  # Load the CSV file
17
  try:
 
11
  from fastapi import HTTPException
12
  from population.models.schemas import ContinentPopulationResponse, CountryPopulation
13
 
14
+ file_path = "D:/backapp/world_population.csv"
15
 
16
  # Load the CSV file
17
  try:
utils/logger.py CHANGED
@@ -2,7 +2,7 @@ import logging
2
  import os
3
 
4
  # Ensure the 'logs' directory exists
5
- log_dir = "D:/pydantic/new/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 = "D:/backapp/population/logs"
6
  os.makedirs(log_dir, exist_ok=True)
7
 
8
  # Configure logging