Sanshruth commited on
Commit
4669654
1 Parent(s): b5167a4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -10
Dockerfile CHANGED
@@ -4,23 +4,47 @@ FROM python:3.10
4
  # Install system dependencies (for H2O & Java)
5
  RUN apt-get update && apt-get install -y openjdk-17-jre-headless
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Install Python dependencies
8
- COPY requirements.txt requirements.txt
9
  RUN pip install --no-cache-dir -r requirements.txt
10
 
11
- # Set JAVA_HOME
12
- ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
13
- ENV PATH=$JAVA_HOME/bin:$PATH
14
-
15
  # Copy your application code
16
- COPY . /app
17
- WORKDIR /app
 
 
 
 
 
 
 
 
18
 
19
- # Create the saved_models directory and set permissions
20
- RUN mkdir -p /app/saved_models && chmod 777 /app/saved_models
21
 
22
  # Expose the port Streamlit runs on
23
  EXPOSE 7860
24
 
25
  # Run Streamlit app
26
- CMD streamlit run app.py --server.port 7860 --server.address 0.0.0.0
 
4
  # Install system dependencies (for H2O & Java)
5
  RUN apt-get update && apt-get install -y openjdk-17-jre-headless
6
 
7
+ # Set environment variables
8
+ ENV PYTHONUNBUFFERED=1 \
9
+ PYTHONDONTWRITEBYTECODE=1 \
10
+ JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
11
+ PATH="$JAVA_HOME/bin:$PATH" \
12
+ STREAMLIT_SERVER_PORT=7860 \
13
+ STREAMLIT_SERVER_ADDRESS=0.0.0.0
14
+
15
+ # Create a non-root user
16
+ RUN useradd -m -s /bin/bash streamlit
17
+
18
+ # Create app directory and set permissions
19
+ RUN mkdir -p /app /app/saved_models /app/.streamlit \
20
+ && chown -R streamlit:streamlit /app
21
+
22
+ # Set working directory
23
+ WORKDIR /app
24
+
25
+ # Copy requirements file
26
+ COPY requirements.txt .
27
+
28
  # Install Python dependencies
 
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
 
 
 
 
31
  # Copy your application code
32
+ COPY . .
33
+
34
+ # Create Streamlit config file
35
+ RUN echo '[server]' > /app/.streamlit/config.toml \
36
+ && echo 'maxUploadSize = 200' >> /app/.streamlit/config.toml
37
+
38
+ # Set permissions
39
+ RUN chmod -R 755 /app \
40
+ && chmod -R 777 /app/saved_models \
41
+ && chown -R streamlit:streamlit /app
42
 
43
+ # Switch to non-root user
44
+ USER streamlit
45
 
46
  # Expose the port Streamlit runs on
47
  EXPOSE 7860
48
 
49
  # Run Streamlit app
50
+ CMD ["streamlit", "run", "app.py"]