hannabaker commited on
Commit
4c56981
·
verified ·
1 Parent(s): b581540

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -33
Dockerfile CHANGED
@@ -1,6 +1,7 @@
1
- FROM python:3.9-slim
 
2
 
3
- # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  fcrackzip \
6
  john \
@@ -8,42 +9,23 @@ RUN apt-get update && apt-get install -y \
8
  unzip \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Create a non-root user with UID 1000 (required by HF Spaces)
12
  RUN useradd -m -u 1000 user
 
 
13
 
14
- # Install Python dependencies
15
- COPY --chown=user requirements.txt /app/requirements.txt
16
- RUN pip install --no-cache-dir -r /app/requirements.txt
17
-
18
- # Set working directory
19
  WORKDIR /app
20
 
21
- # Copy application files with correct ownership
22
- COPY --chown=user . /app
23
-
24
- # Create necessary directories with correct permissions
25
- RUN mkdir -p /app/uploads && chown -R user:user /app
26
 
27
- # Create matplotlib config directory
28
- RUN mkdir -p /home/user/.config/matplotlib && \
29
- mkdir -p /home/user/.cache && \
30
- chown -R user:user /home/user/.config && \
31
- chown -R user:user /home/user/.cache
32
-
33
- # Switch to the non-root user
34
- USER user
35
-
36
- # Set environment variables
37
- ENV HOME=/home/user \
38
- PATH=/home/user/.local/bin:$PATH \
39
- GRADIO_SERVER_NAME="0.0.0.0" \
40
- GRADIO_SERVER_PORT="7860" \
41
- MPLCONFIGDIR=/home/user/.config/matplotlib \
42
- MATPLOTLIB_CACHE_DIR=/home/user/.cache/matplotlib \
43
- PYTHONUNBUFFERED=1
44
 
45
- # Expose port
46
- EXPOSE 7860
 
47
 
48
- # Run the application
49
  CMD ["python", "app.py"]
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ FROM python:3.9
3
 
4
+ # Install system dependencies first
5
  RUN apt-get update && apt-get install -y \
6
  fcrackzip \
7
  john \
 
9
  unzip \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create user AFTER installing system packages
13
  RUN useradd -m -u 1000 user
14
+ USER user
15
+ ENV PATH="/home/user/.local/bin:$PATH"
16
 
 
 
 
 
 
17
  WORKDIR /app
18
 
19
+ # Copy and install Python requirements
20
+ COPY --chown=user ./requirements.txt requirements.txt
21
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
22
 
23
+ # Copy app files
24
+ COPY --chown=user . /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ # Set environment variables for matplotlib
27
+ ENV MPLCONFIGDIR=/tmp/matplotlib
28
+ ENV HOME=/home/user
29
 
30
+ # Run Gradio app
31
  CMD ["python", "app.py"]