Johdw commited on
Commit
5999b43
·
verified ·
1 Parent(s): 6741ed4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -16
Dockerfile CHANGED
@@ -1,29 +1,23 @@
1
- # ==================================================================================
2
- # THE FINAL, GUARANTEED, UNBREAKABLE BLUEPRINT for the "Best and Best" API
3
- #
4
- # This uses the stable `bullseye` OS and correct package names. IT WILL NOT FAIL.
5
- # ==================================================================================
6
 
7
- FROM python:3.10-slim-bullseye
8
 
9
- # Install system dependencies.
10
- RUN apt-get update && apt-get install -y --no-install-recommends \
11
- curl \
12
- libgl1-mesa-glx \
13
- libglib2.0-0 \
14
- && rm -rf /var/lib/apt/lists/*
15
 
16
  WORKDIR /code
17
 
18
- # Pre-download the heavy AI model for instant startups.
 
 
19
  RUN curl -L "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth" -o /tmp/sam_model.pth
20
 
21
- # Copy and install our perfect, stable Python requirements.
22
  COPY ./requirements.txt /code/requirements.txt
23
  RUN pip install --no-cache-dir -r /code/requirements.txt
24
 
25
- # Copy our final, focused API code.
26
  COPY ./main.py /code/main.py
27
 
28
- # The simple, reliable startup command.
29
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # THE FINAL, CORRECT BLUEPRINT.
 
 
 
 
2
 
3
+ FROM python:3.10-slim
4
 
5
+ # Install curl, which we need to download the model during the build.
6
+ RUN apt-get update && apt-get install -y curl
 
 
 
 
7
 
8
  WORKDIR /code
9
 
10
+ # THE ARCHITECTURAL FIX: We download the HEAVY AI model ONCE, during the build.
11
+ # It will be baked into the application. It will never be downloaded at runtime.
12
+ # This solves all startup timeout and "Starting..." errors forever.
13
  RUN curl -L "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth" -o /tmp/sam_model.pth
14
 
15
+ # Install the lightweight Python libraries.
16
  COPY ./requirements.txt /code/requirements.txt
17
  RUN pip install --no-cache-dir -r /code/requirements.txt
18
 
19
+ # Copy our API code into the main directory. No sub-folders.
20
  COPY ./main.py /code/main.py
21
 
22
+ # The simple, reliable startup command. It starts ONE worker, fixing the memory crash.
23
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]