Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +36 -4
Dockerfile
CHANGED
@@ -1,5 +1,37 @@
|
|
1 |
-
FROM python:3.9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
COPY requirements.txt .
|
3 |
-
RUN pip install -r requirements.txt
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
# Set environment variables
|
4 |
+
ENV PYTHONUNBUFFERED=1 \
|
5 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
6 |
+
PORT=7860 \
|
7 |
+
TRANSFORMERS_CACHE=/tmp/huggingface
|
8 |
+
|
9 |
+
# Set the working directory
|
10 |
+
WORKDIR /code
|
11 |
+
|
12 |
+
# Install system dependencies
|
13 |
+
RUN apt-get update && apt-get install -y \
|
14 |
+
build-essential \
|
15 |
+
curl \
|
16 |
+
&& rm -rf /var/lib/apt/lists/*
|
17 |
+
|
18 |
+
# Create cache directory with proper permissions
|
19 |
+
RUN mkdir -p /tmp/huggingface && chmod 777 /tmp/huggingface
|
20 |
+
|
21 |
+
# Install Python dependencies
|
22 |
COPY requirements.txt .
|
23 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
24 |
+
|
25 |
+
# Copy the application
|
26 |
+
COPY ./app /code/app
|
27 |
+
|
28 |
+
# Make port 7860 available
|
29 |
+
EXPOSE 7860
|
30 |
+
|
31 |
+
# Create a non-root user and switch to it
|
32 |
+
RUN adduser --disabled-password --gecos "" appuser && \
|
33 |
+
chown -R appuser:appuser /code /tmp/huggingface
|
34 |
+
USER appuser
|
35 |
+
|
36 |
+
# Run the application
|
37 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|