joytheslothh commited on
Commit
c27fef7
·
1 Parent(s): 6ad81c6

Final Update: Optimized FastAPI backend with root landing page for Vercel frontend connectivity

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -13
Dockerfile CHANGED
@@ -1,31 +1,30 @@
1
- FROM python:3.10-slim
2
 
3
- # Install system dependencies for OpenCV and scikit-image
4
  RUN apt-get update && apt-get install -y \
5
- libgl1-mesa-glx \
6
  libglib2.0-0 \
 
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- # Set up a new user named "user" with user ID 1000
10
  RUN useradd -m -u 1000 user
11
  USER user
12
  ENV PATH="/home/user/.local/bin:$PATH"
13
-
14
- # Set the working directory to the user's home directory
15
  WORKDIR /home/user/app
16
 
17
- # Copy the requirements file into the container
18
  COPY --chown=user requirements.txt .
19
-
20
- # Install the Python dependencies
21
  RUN pip install --no-cache-dir --upgrade pip
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
- # Copy the rest of the application code into the container
25
  COPY --chown=user . .
26
 
27
- # Hugging Face Spaces expects the app to run on port 7860
28
  EXPOSE 7860
29
 
30
- # Command to run the FastAPI application
31
- CMD ["uvicorn", "bacterial-classifier.api:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.11-slim
2
 
3
+ # Install system dependencies for OpenCV and ML
4
  RUN apt-get update && apt-get install -y \
5
+ libgl1 \
6
  libglib2.0-0 \
7
+ libsm6 \
8
+ libxrender1 \
9
+ libxext6 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Set up user
13
  RUN useradd -m -u 1000 user
14
  USER user
15
  ENV PATH="/home/user/.local/bin:$PATH"
 
 
16
  WORKDIR /home/user/app
17
 
18
+ # Install Python dependencies
19
  COPY --chown=user requirements.txt .
 
 
20
  RUN pip install --no-cache-dir --upgrade pip
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy source code
24
  COPY --chown=user . .
25
 
26
+ # Hugging Face usually expects 7860
27
  EXPOSE 7860
28
 
29
+ # Run FastAPI
30
+ CMD ["uvicorn", "classifier_service.api:app", "--host", "0.0.0.0", "--port", "7860"]