msg
Browse files- Dockerfile +18 -9
Dockerfile
CHANGED
|
@@ -1,20 +1,29 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy
|
| 8 |
-
COPY . /app
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Install dependencies
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use the official Python image from Docker Hub
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# Set the working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy the application files
|
| 8 |
+
COPY app.py /app/
|
| 9 |
+
COPY requirements.txt /app/
|
| 10 |
|
| 11 |
+
# Create a writable cache directory for Hugging Face
|
| 12 |
+
ENV HF_HOME=/app/hf_cache
|
| 13 |
+
RUN mkdir -p /app/hf_cache
|
| 14 |
+
|
| 15 |
+
# Set permissions for the cache directory
|
| 16 |
+
RUN chmod -R 777 /app/hf_cache
|
| 17 |
|
| 18 |
# Install dependencies
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
+
# Create a non-root user and switch to it
|
| 22 |
+
RUN useradd -m appuser
|
| 23 |
+
USER appuser
|
| 24 |
+
|
| 25 |
+
# Expose the Streamlit port
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
+
# Run the Streamlit app
|
| 29 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|