Spaces:
Sleeping
Sleeping
Regino
commited on
Commit
Β·
8faa6ae
1
Parent(s):
95a3efa
fixed permission
Browse files- Dockerfile +30 -18
Dockerfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
|
|
|
|
|
4 |
|
5 |
# Install system dependencies required by OpenCV and other build tools
|
6 |
# libgl1-mesa-glx: Provides libGL.so.1 (OpenGL library) - THIS IS THE KEY FIX
|
@@ -16,28 +18,38 @@ RUN apt-get update && apt-get install -y \
|
|
16 |
libsm6 \
|
17 |
libxrender1 \
|
18 |
ffmpeg \
|
|
|
|
|
19 |
# Clean up apt caches to reduce image size
|
20 |
&& rm -rf /var/lib/apt/lists/*
|
21 |
|
22 |
-
#
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
-
#
|
|
|
26 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
27 |
|
28 |
-
#
|
29 |
-
# This
|
30 |
-
|
31 |
-
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
#
|
36 |
-
#
|
37 |
-
# βββ requirements.txt
|
38 |
-
# βββ Dockerfile
|
39 |
-
#
|
40 |
-
# COPY . . copies everything from your project_root into /app in the container.
|
41 |
COPY . .
|
42 |
|
43 |
EXPOSE 8501
|
@@ -45,5 +57,5 @@ EXPOSE 8501
|
|
45 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
46 |
|
47 |
# Ensure the entrypoint path is correct for your app within the container
|
48 |
-
# Based on your structure, it's inside 'src/'
|
49 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
# Define arguments for user ID and group ID (optional, but good for consistency)
|
4 |
+
ARG UID=1000
|
5 |
+
ARG GID=1000
|
6 |
|
7 |
# Install system dependencies required by OpenCV and other build tools
|
8 |
# libgl1-mesa-glx: Provides libGL.so.1 (OpenGL library) - THIS IS THE KEY FIX
|
|
|
18 |
libsm6 \
|
19 |
libxrender1 \
|
20 |
ffmpeg \
|
21 |
+
# Add tools for user management
|
22 |
+
useradd \
|
23 |
# Clean up apt caches to reduce image size
|
24 |
&& rm -rf /var/lib/apt/lists/*
|
25 |
|
26 |
+
# Create a non-root user and group
|
27 |
+
# -m: create home directory
|
28 |
+
# -u ${UID}: assign specific UID (optional, but good for host volume mounting)
|
29 |
+
# -g appgroup: assign to appgroup
|
30 |
+
RUN groupadd -g ${GID} appgroup && \
|
31 |
+
useradd -m -u ${UID} -g appgroup appuser
|
32 |
+
|
33 |
+
# Set the HOME environment variable for the new user
|
34 |
+
ENV HOME /home/appuser
|
35 |
+
|
36 |
+
# Set the working directory for the application
|
37 |
+
# We'll put it in /app and then change ownership so the non-root user can write to it
|
38 |
+
WORKDIR /app
|
39 |
|
40 |
+
# Copy your requirements.txt file and install Python dependencies (as root, for system-wide install)
|
41 |
+
COPY requirements.txt .
|
42 |
RUN pip3 install --no-cache-dir -r requirements.txt
|
43 |
|
44 |
+
# Change ownership of the /app directory to the new non-root user
|
45 |
+
# This is crucial so that the 'appuser' can read/write in its working directory
|
46 |
+
RUN chown -R appuser:appgroup /app
|
47 |
+
|
48 |
+
# Switch to the non-root user for subsequent commands
|
49 |
+
USER appuser
|
50 |
+
|
51 |
+
# Copy your application source code and assets into the /app directory
|
52 |
+
# Now, these files will be owned by 'appuser'
|
|
|
|
|
|
|
|
|
53 |
COPY . .
|
54 |
|
55 |
EXPOSE 8501
|
|
|
57 |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
58 |
|
59 |
# Ensure the entrypoint path is correct for your app within the container
|
60 |
+
# Based on your structure, it's inside 'src/' relative to the WORKDIR /app
|
61 |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|