Update Dockerfile
Browse files- Dockerfile +27 -20
Dockerfile
CHANGED
@@ -1,45 +1,52 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
# Set environment variables to make Python and Pip output unbuffered (good for logs)
|
4 |
ENV PYTHONUNBUFFERED=1
|
5 |
|
6 |
-
# Install system dependencies including ffmpeg
|
7 |
RUN apt-get update && \
|
8 |
apt-get install -y --no-install-recommends ffmpeg libsm6 libxext6 && \
|
9 |
apt-get clean && \
|
10 |
rm -rf /var/lib/apt/lists/*
|
11 |
|
12 |
-
# Create a non-root user and group
|
13 |
ARG APP_USER_UID=1000
|
14 |
ARG APP_USER_GID=1000
|
15 |
RUN groupadd --gid $APP_USER_GID appgroup && \
|
16 |
useradd --uid $APP_USER_UID --gid appgroup --shell /bin/bash --create-home appuser
|
17 |
|
18 |
-
# Set the working directory (this will also be appuser's home directory due to --create-home)
|
19 |
WORKDIR /home/appuser/app
|
20 |
|
21 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
COPY requirements.txt ./
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
# Install Python dependencies
|
25 |
-
# Ensure pip is up to date, then install requirements
|
26 |
-
RUN pip install --no-cache-dir --upgrade pip
|
27 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
-
# Copy the rest of the application code
|
30 |
COPY . .
|
31 |
-
|
32 |
-
# Change ownership of the app directory to the appuser
|
33 |
-
# (WORKDIR is /home/appuser/app, so chown this path)
|
34 |
RUN chown -R appuser:appgroup /home/appuser/app
|
35 |
-
|
36 |
-
# Switch to the non-root user
|
37 |
USER appuser
|
38 |
|
39 |
-
# Expose Streamlit's default port
|
40 |
EXPOSE 8501
|
41 |
-
|
42 |
-
# Command to run Streamlit
|
43 |
-
# Using server.headless=true is good practice for containers.
|
44 |
-
# Streamlit will try to create .streamlit in the user's home dir (/home/appuser)
|
45 |
CMD ["streamlit", "run", "app.py", "--server.headless=true"]
|
|
|
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"]
|