wayne-chi commited on
Commit
aee963f
·
verified ·
1 Parent(s): 3902368

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -19
Dockerfile CHANGED
@@ -1,32 +1,33 @@
1
  FROM python:3.9-slim
2
 
3
- # Create a non-root user to avoid permission issues at runtime
4
- RUN useradd -m -u 1000 user
5
-
6
- # Set WORKDIR early so file ownership applies correctly
7
  WORKDIR /app
8
 
9
- # Copy dependencies; specify ownership to avoid permission issues
10
- COPY --chown=user requirements.txt ./
 
 
 
 
 
 
 
 
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy rest of your app into /app with correct ownership
14
- COPY --chown=user . .
15
 
16
- # Set the user to non-root for runtime
17
- USER user
18
- ENV HOME=/home/user
19
- WORKDIR /app
20
 
21
- # Create a writable directory for files like fuel_properties.csv
22
- RUN mkdir -p data && chmod 777 data
23
 
24
- # Optionally set environment variables to ensure cache and configs are writable
25
- ENV MPLCONFIGDIR=/home/user/.config/matplotlib \
26
- HF_HOME=/home/user/.cache/huggingface
27
 
28
- # Execute setup script during build
29
- RUN chmod +x setup.sh && ./setup.sh
30
 
31
  # Expose the port and run your app
32
  EXPOSE 7860
 
1
  FROM python:3.9-slim
2
 
3
+ # Set working directory
 
 
 
4
  WORKDIR /app
5
 
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ build-essential \
9
+ git \
10
+ curl \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Copy requirements first (for better caching)
14
+ COPY requirements.txt .
15
+
16
+ # Install Python dependencies
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copy all app files into container
20
+ COPY . .
21
 
22
+ # Make setup.sh executable
23
+ RUN chmod +x setup.sh
 
 
24
 
25
+ # Run setup.sh at build time so models are preloaded
26
+ RUN ./setup.sh
27
 
28
+ # Expose Streamlit port
29
+ EXPOSE 7860
 
30
 
 
 
31
 
32
  # Expose the port and run your app
33
  EXPOSE 7860