Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +29 -0
Dockerfile
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Use the base image with the correct Python version (e.g., Python 3.9)
|
| 3 |
+
FROM python:3.9
|
| 4 |
+
|
| 5 |
+
# Create a new user with user ID 1000 (e.g., user)
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
|
| 8 |
+
# Switch to the created user for subsequent commands
|
| 9 |
+
USER user
|
| 10 |
+
|
| 11 |
+
# Update the PATH environment variable to include the user's local bin
|
| 12 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 13 |
+
|
| 14 |
+
# Set the working directory inside the container
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
# Copy requirements.txt and set the ownership to the created user
|
| 18 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 19 |
+
|
| 20 |
+
# Install the required Python dependencies without caching
|
| 21 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 22 |
+
|
| 23 |
+
# Copy the rest of the application files to the working directory
|
| 24 |
+
COPY --chown=user . /app
|
| 25 |
+
|
| 26 |
+
# Start the Streamlit app on port 7860, which is the default port expected by Hugging Face Spaces
|
| 27 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
| 28 |
+
|
| 29 |
+
# Reference: https://huggingface.co/docs/hub/en/spaces-sdks-docker
|