Sumkh commited on
Commit
6cb2fb4
·
verified ·
1 Parent(s): 6d43bdb

Upload 3 files

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -5
Dockerfile CHANGED
@@ -1,23 +1,30 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.11-slim
3
 
 
 
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
6
 
7
  # Set working directory
8
  WORKDIR /app
9
 
10
- # Create a writable config directory for matplotlib and set environment variable
11
- RUN mkdir -p /app/.config/matplotlib && chmod -R 777 /app/.config
12
- ENV MPLCONFIGDIR=/app/.config/matplotlib
 
 
13
  ENV HF_HOME=/app/.cache
 
 
14
  ENV USER_AGENT="my-gradio-app"
15
 
16
  # Copy the requirements file and install dependencies
17
  COPY requirements.txt .
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy the rest of the code
21
  COPY . .
22
 
23
  # Expose the port for Gradio (Spaces expects the app on port 7860)
 
1
+ # Use Python 3.11 slim image
2
  FROM python:3.11-slim
3
 
4
+ # Ensure we run as root (the default) so we can set permissions
5
+ USER root
6
+
7
  # Install system dependencies
8
  RUN apt-get update && apt-get install -y wget && rm -rf /var/lib/apt/lists/*
9
 
10
  # Set working directory
11
  WORKDIR /app
12
 
13
+ # Create and set permissions for cache directories
14
+ RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache \
15
+ && mkdir -p /app/.config/matplotlib && chmod -R 777 /app/.config/matplotlib
16
+
17
+ # Set environment variables for cache directories
18
  ENV HF_HOME=/app/.cache
19
+ ENV XDG_CACHE_HOME=/app/.cache
20
+ ENV MPLCONFIGDIR=/app/.config/matplotlib
21
  ENV USER_AGENT="my-gradio-app"
22
 
23
  # Copy the requirements file and install dependencies
24
  COPY requirements.txt .
25
  RUN pip install --no-cache-dir -r requirements.txt
26
 
27
+ # Copy the rest of the application code
28
  COPY . .
29
 
30
  # Expose the port for Gradio (Spaces expects the app on port 7860)