Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +22 -14
Dockerfile
CHANGED
@@ -1,35 +1,43 @@
|
|
1 |
-
# Use the official Python image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
# Set the working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Create a
|
8 |
-
RUN
|
9 |
-
chmod -R 777 /workspace/huggingface_cache
|
10 |
|
11 |
-
#
|
12 |
-
|
|
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
ENV TRITON_CACHE_DIR=/
|
17 |
|
18 |
# Install system dependencies
|
19 |
-
RUN apt-get update && apt-get install -y git
|
|
|
|
|
|
|
20 |
|
21 |
# Copy the requirements file into the image
|
22 |
COPY requirements.txt requirements.txt
|
23 |
|
24 |
-
# Install
|
25 |
RUN pip install --no-cache-dir -r requirements.txt
|
26 |
|
27 |
-
# Copy the rest of
|
28 |
COPY . .
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Expose the port your application will run on
|
31 |
EXPOSE 7860
|
32 |
|
33 |
-
#
|
34 |
CMD ["python", "app.py"]
|
35 |
-
|
|
|
1 |
+
# Use the official Python image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
# Set the working directory
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Create a non-root user
|
8 |
+
RUN useradd -m appuser
|
|
|
9 |
|
10 |
+
# Create writable directories for Hugging Face and Triton cache
|
11 |
+
RUN mkdir -p /workspace/huggingface_cache /home/appuser/.triton && \
|
12 |
+
chmod -R 777 /workspace/huggingface_cache /home/appuser/.triton
|
13 |
|
14 |
+
# Set environment variables
|
15 |
+
ENV HF_HOME=/workspace/huggingface_cache
|
16 |
+
ENV TRITON_CACHE_DIR=/home/appuser/.triton
|
17 |
|
18 |
# Install system dependencies
|
19 |
+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
20 |
+
|
21 |
+
# Set umask to ensure proper file permissions
|
22 |
+
RUN umask 002
|
23 |
|
24 |
# Copy the requirements file into the image
|
25 |
COPY requirements.txt requirements.txt
|
26 |
|
27 |
+
# Install required packages
|
28 |
RUN pip install --no-cache-dir -r requirements.txt
|
29 |
|
30 |
+
# Copy the rest of the application code
|
31 |
COPY . .
|
32 |
|
33 |
+
# Change ownership to non-root user
|
34 |
+
RUN chown -R appuser:appuser /app /workspace/huggingface_cache /home/appuser/.triton
|
35 |
+
|
36 |
+
# Switch to non-root user
|
37 |
+
USER appuser
|
38 |
+
|
39 |
# Expose the port your application will run on
|
40 |
EXPOSE 7860
|
41 |
|
42 |
+
# Run the application
|
43 |
CMD ["python", "app.py"]
|
|