Spaces:
Sleeping
Sleeping
Commit ·
a2551a8
1
Parent(s): 57b2069
Fix Dockerfile: Add proper user setup for HF Spaces
Browse files- Create user with UID 1000 (required by HF Spaces)
- Set HOME and PATH environment variables
- Switch to non-root user before pip install
- Fix permission issues with git config commands
- Use --chown for proper file ownership
This fixes the "could not lock config file" error.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Dockerfile +21 -12
Dockerfile
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
# Dockerfile for Hugging Face Spaces - Streamlit App
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Set working directory
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
# Install system dependencies (including git and wget for HF Spaces)
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
|
@@ -12,24 +9,36 @@ RUN apt-get update && apt-get install -y \
|
|
| 12 |
git \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Install Python dependencies
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
-
# Copy application files
|
| 22 |
-
COPY app.py .
|
| 23 |
-
COPY log_parser.py .
|
| 24 |
|
| 25 |
# Expose port 7860 (Hugging Face Spaces default)
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
# Set environment variables for Streamlit
|
| 29 |
-
ENV STREAMLIT_SERVER_PORT=7860
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
# Run the application
|
| 35 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
|
| 1 |
# Dockerfile for Hugging Face Spaces - Streamlit App
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Install system dependencies (including git and wget for HF Spaces)
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
|
|
|
| 9 |
git \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Create user with UID 1000 (required by HF Spaces)
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
+
# Set home directory and working directory
|
| 16 |
+
ENV HOME=/home/user \
|
| 17 |
+
PATH=/home/user/.local/bin:$PATH
|
| 18 |
+
|
| 19 |
+
WORKDIR $HOME/app
|
| 20 |
+
|
| 21 |
+
# Copy requirements file and change ownership
|
| 22 |
+
COPY --chown=user:user requirements.txt .
|
| 23 |
+
|
| 24 |
+
# Switch to user before installing dependencies
|
| 25 |
+
USER user
|
| 26 |
|
| 27 |
# Install Python dependencies
|
| 28 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 29 |
|
| 30 |
+
# Copy application files with proper ownership
|
| 31 |
+
COPY --chown=user:user app.py .
|
| 32 |
+
COPY --chown=user:user log_parser.py .
|
| 33 |
|
| 34 |
# Expose port 7860 (Hugging Face Spaces default)
|
| 35 |
EXPOSE 7860
|
| 36 |
|
| 37 |
# Set environment variables for Streamlit
|
| 38 |
+
ENV STREAMLIT_SERVER_PORT=7860 \
|
| 39 |
+
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
|
| 40 |
+
STREAMLIT_SERVER_HEADLESS=true \
|
| 41 |
+
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
| 42 |
|
| 43 |
# Run the application
|
| 44 |
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|