Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +26 -26
Dockerfile
CHANGED
|
@@ -1,35 +1,35 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
|
|
|
| 1 |
+
# Use minimal Python base image
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
WORKDIR /code
|
| 5 |
|
| 6 |
+
# Install system dependencies
|
| 7 |
+
RUN apt update && apt install -y --no-install-recommends \
|
| 8 |
+
libssl-dev \
|
| 9 |
+
libffi-dev \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Copy only requirements first
|
| 13 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 14 |
|
| 15 |
+
# Install all dependencies from `requirements.txt`
|
| 16 |
+
RUN pip install --no-cache-dir --prefer-binary -r /code/requirements.txt
|
| 17 |
|
| 18 |
+
# Install `accelerate` separately WITHOUT dependencies (prevents `torch` installation)
|
| 19 |
+
RUN pip install --no-cache-dir --no-deps accelerate==0.26.0
|
| 20 |
+
RUN pip install --no-cache-dir --no-deps sentence_transformers==3.3.0
|
| 21 |
+
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
|
| 22 |
+
# Copy application code
|
| 23 |
+
COPY ./app /code/app
|
| 24 |
+
COPY ./startup.sh /code/startup.sh
|
| 25 |
|
| 26 |
+
# Set script permissions
|
| 27 |
+
RUN chmod +x /code/startup.sh
|
| 28 |
|
| 29 |
+
# Use a non-root user
|
| 30 |
+
RUN useradd -m appuser
|
| 31 |
+
USER appuser
|
| 32 |
|
| 33 |
+
EXPOSE 80
|
| 34 |
|
| 35 |
+
CMD ["sh", "/code/startup.sh"]
|