UDface11jkj commited on
Commit
33262f5
·
verified ·
1 Parent(s): 33d4e83

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -14
Dockerfile CHANGED
@@ -1,14 +1,16 @@
1
- # Use the official lightweight Python image
2
  FROM python:3.10-slim
3
 
4
- # Set environment variables to avoid prompts during installs
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
 
8
- # Set working directory to home/streamlit_user (non-root user directory)
 
 
 
9
  WORKDIR /home/streamlit_user/app
10
 
11
- # Install system dependencies (including for image processing and huggingface)
12
  RUN apt-get update && apt-get install -y --no-install-recommends \
13
  build-essential \
14
  git \
@@ -16,28 +18,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
16
  libgl1-mesa-glx \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
- # Create a directory for model weights under the user directory and set permissions
20
  RUN mkdir -p /home/streamlit_user/step1x_weights && \
21
- chown -R streamlit_user:streamlit_user /home/streamlit_user/step1x_weights
22
 
23
- # Copy requirements.txt first to leverage Docker cache
24
  COPY requirements.txt ./requirements.txt
25
-
26
- # Install Python dependencies
27
  RUN pip install --upgrade pip && \
28
  pip install --no-cache-dir -r requirements.txt
29
 
30
- # Copy the rest of your app files
31
  COPY src/ ./src/
32
 
33
- # Set user for the app
34
  USER streamlit_user
35
 
36
- # Expose Streamlit default port
37
  EXPOSE 8501
38
 
39
- # Streamlit specific environment variable to disable browser opening
40
  ENV STREAMLIT_SERVER_HEADLESS=true
41
 
42
- # Run the Streamlit app
43
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Set environment variables
4
  ENV PYTHONDONTWRITEBYTECODE=1
5
  ENV PYTHONUNBUFFERED=1
6
 
7
+ # Create a non-root user and home directory
8
+ RUN useradd -m -s /bin/bash streamlit_user
9
+
10
+ # Set working directory
11
  WORKDIR /home/streamlit_user/app
12
 
13
+ # Install system dependencies
14
  RUN apt-get update && apt-get install -y --no-install-recommends \
15
  build-essential \
16
  git \
 
18
  libgl1-mesa-glx \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Create model weights directory and assign ownership
22
  RUN mkdir -p /home/streamlit_user/step1x_weights && \
23
+ chown -R streamlit_user:streamlit_user /home/streamlit_user
24
 
25
+ # Copy requirements and install Python dependencies
26
  COPY requirements.txt ./requirements.txt
 
 
27
  RUN pip install --upgrade pip && \
28
  pip install --no-cache-dir -r requirements.txt
29
 
30
+ # Copy app source code
31
  COPY src/ ./src/
32
 
33
+ # Change user to non-root
34
  USER streamlit_user
35
 
36
+ # Expose Streamlit port
37
  EXPOSE 8501
38
 
39
+ # Environment settings for Streamlit
40
  ENV STREAMLIT_SERVER_HEADLESS=true
41
 
42
+ # Run the app
43
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]