Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +23 -0
Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"]
|