mgbam commited on
Commit
264ac69
·
verified ·
1 Parent(s): b97795f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -35
Dockerfile CHANGED
@@ -1,52 +1,50 @@
1
  FROM python:3.10-slim
2
 
 
3
  ENV PYTHONUNBUFFERED=1
 
4
 
 
 
 
5
  RUN apt-get update && \
6
- apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
7
- apt-get clean && \
 
 
 
 
 
 
 
 
8
  rm -rf /var/lib/apt/lists/*
9
 
 
10
  ARG APP_USER_UID=1000
11
  ARG APP_USER_GID=1000
12
  RUN groupadd --gid $APP_USER_GID appgroup && \
13
  useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
14
 
 
15
  WORKDIR /home/appuser/app
16
 
17
- # Upgrade pip first
18
- RUN pip install --no-cache-dir --upgrade pip
19
-
20
- # Attempt to install moviepy and key dependencies explicitly first
21
- # Adding print statements to check versions during build
22
- RUN echo "Python version: $(python --version)" && \
23
- echo "Pip version: $(pip --version)" && \
24
- echo "Attempting explicit MoviePy installation..." && \
25
- pip install --no-cache-dir \
26
- "numpy>=1.17" \
27
- "decorator>=4.0.2" \
28
- "proglog>=0.1.9" \
29
- "imageio>=2.5" \
30
- "imageio-ffmpeg>=0.4.0" \
31
- "moviepy>=1.0.3" && \
32
- echo "Explicit MoviePy installation attempt finished." && \
33
- echo "Checking installed packages:" && \
34
- pip list
35
-
36
- COPY requirements.txt ./
37
- # Ensure requirements.txt doesn't also list moviepy if installed explicitly above
38
- # or ensure versions are compatible. For now, let's assume moviepy is *only* installed above.
39
- # If moviepy is also in requirements.txt, pip might try to reinstall or change version.
40
- RUN echo "Installing packages from requirements.txt..." && \
41
- pip install --no-cache-dir -r requirements.txt && \
42
- echo "Finished installing from requirements.txt." && \
43
- echo "Final check of installed packages:" && \
44
- pip list
45
-
46
-
47
- COPY . .
48
- RUN chown -R appuser:appgroup /home/appuser/app
49
  USER appuser
 
 
 
 
 
 
50
 
 
51
  EXPOSE 8501
52
- CMD ["streamlit", "run", "app.py", "--server.headless=true"]
 
 
 
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Set environment variables
4
  ENV PYTHONUNBUFFERED=1
5
+ ENV DEBIAN_FRONTEND=noninteractive # Prevents interactive prompts during apt-get install
6
 
7
+ # Install system dependencies including ffmpeg and fonts
8
+ # Using ttf-mscorefonts-installer for Arial and other common Microsoft fonts
9
+ # fontconfig is needed to make fonts available to applications
10
  RUN apt-get update && \
11
+ apt-get install -y --no-install-recommends \
12
+ ffmpeg \
13
+ libsm6 \
14
+ libxext6 \
15
+ fontconfig \
16
+ # For Microsoft Core Fonts EULA pre-acceptance
17
+ && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-sections \
18
+ && apt-get install -y --no-install-recommends ttf-mscorefonts-installer \
19
+ && apt-get clean && \
20
+ fc-cache -f -v && \ # Rebuild font cache to make newly installed fonts available
21
  rm -rf /var/lib/apt/lists/*
22
 
23
+ # Create a non-root user and group for security and permission handling
24
  ARG APP_USER_UID=1000
25
  ARG APP_USER_GID=1000
26
  RUN groupadd --gid $APP_USER_GID appgroup && \
27
  useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
28
 
29
+ # Set the working directory (this will also be appuser's home directory)
30
  WORKDIR /home/appuser/app
31
 
32
+ # Copy requirements.txt first to leverage Docker build cache
33
+ COPY --chown=appuser:appgroup requirements.txt ./
34
+
35
+ # Upgrade pip and install Python dependencies as the appuser
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  USER appuser
37
+ RUN python -m pip install --no-cache-dir --upgrade pip
38
+ RUN python -m pip install --no-cache-dir -r requirements.txt
39
+
40
+ # Copy the rest of the application code as the appuser
41
+ # This ensures correct ownership from the start
42
+ COPY --chown=appuser:appgroup . .
43
 
44
+ # Expose Streamlit's default port
45
  EXPOSE 8501
46
+
47
+ # Command to run Streamlit
48
+ # Using server.headless=true is good practice for containers.
49
+ # Streamlit will try to create .streamlit in the user's home dir (/home/appuser)
50
+ CMD ["streamlit", "run", "app.py", "--server.headless=true", "--server.port=8501", "--server.fileWatcherType=none"]