Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +20 -15
Dockerfile
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
4 |
WORKDIR /code
|
5 |
|
6 |
# Install system dependencies
|
@@ -10,25 +13,27 @@ RUN apt-get update && apt-get install -y \
|
|
10 |
curl \
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
# Copy requirements and install
|
17 |
-
COPY app/requirements.txt .
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
20 |
-
# Copy the
|
21 |
-
COPY app/
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
# Set
|
24 |
-
|
|
|
25 |
|
26 |
# Expose the port
|
27 |
EXPOSE 7860
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
ENV PORT=7860
|
32 |
|
33 |
-
#
|
34 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
# Create a non-root user
|
4 |
+
RUN useradd -m appuser
|
5 |
+
|
6 |
+
# Set the working directory
|
7 |
WORKDIR /code
|
8 |
|
9 |
# Install system dependencies
|
|
|
13 |
curl \
|
14 |
&& rm -rf /var/lib/apt/lists/*
|
15 |
|
16 |
+
# Copy requirements file and install Python dependencies
|
17 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
20 |
+
# Copy the application code
|
21 |
+
COPY app /code/app
|
22 |
+
COPY main.py .
|
23 |
+
|
24 |
+
# Create models and cache directories and set correct permissions
|
25 |
+
RUN mkdir -p /code/models/.cache/huggingface && \
|
26 |
+
chown -R appuser:appuser /code/models
|
27 |
|
28 |
+
# Set environment variables
|
29 |
+
ENV HOST=0.0.0.0
|
30 |
+
ENV PORT=7860
|
31 |
|
32 |
# Expose the port
|
33 |
EXPOSE 7860
|
34 |
|
35 |
+
# Switch to the non-root user
|
36 |
+
USER appuser
|
|
|
37 |
|
38 |
+
# Command to run the FastAPI app
|
39 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|