Johdw commited on
Commit
6dec936
·
verified ·
1 Parent(s): 3f38925

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -17
Dockerfile CHANGED
@@ -1,23 +1,19 @@
1
- # THE FINAL, GUARANTEED BLUEPRINT. IT WILL NOT FAIL.
2
-
3
  FROM python:3.10-slim
4
 
5
- # This allows us 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 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_b_01ec64.pth" -o /tmp/sam.pth
14
 
15
- # Install the Python libraries from our lightweight requirements file.
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.
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", "80"]
 
1
+ # THE FINAL, CORRECT BLUEPRINT. THIS WILL WORK.
 
2
  FROM python:3.10-slim
3
 
4
+ # Set up a writable directory for our model
5
+ RUN mkdir -p /app/data && chown -R 1000:1000 /app
6
+ WORKDIR /app
 
7
 
8
+ # Copy and install the lightweight requirements
9
+ COPY --chown=1000:1000 requirements.txt .
10
+ RUN pip install --no-cache-dir -r requirements.txt
 
11
 
12
+ # Copy the API code
13
+ COPY --chown=1000:1000 main.py .
 
14
 
15
+ # Explicitly run as the non-root 'user'
16
+ USER 1000
17
 
18
+ # The simple, reliable startup command.
19
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]