Spaces:
Runtime error
Runtime error
NextDrought
commited on
Commit
•
9cdfb13
1
Parent(s):
59977de
Run as nob-root user
Browse files- Dockerfile +15 -6
Dockerfile
CHANGED
@@ -4,9 +4,6 @@ FROM python:3.10
|
|
4 |
# Set the working directory in the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
# Change permissions to allow all users to write to the /app directory
|
8 |
-
RUN chmod 777 /app
|
9 |
-
|
10 |
# Install system dependencies
|
11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
12 |
build-essential \
|
@@ -22,12 +19,24 @@ ENV GDAL_CONFIG=/usr/bin/gdal-config
|
|
22 |
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
|
23 |
ENV C_INCLUDE_PATH=/usr/include/gdal
|
24 |
|
|
|
|
|
|
|
25 |
# Copy the requirements file into the container
|
26 |
-
COPY . .
|
27 |
|
28 |
# Install Python dependencies
|
29 |
-
RUN pip install --no-cache-dir --upgrade pip \
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# Expose port 8501 for Streamlit
|
33 |
EXPOSE 8501
|
|
|
4 |
# Set the working directory in the container
|
5 |
WORKDIR /app
|
6 |
|
|
|
|
|
|
|
7 |
# Install system dependencies
|
8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
9 |
build-essential \
|
|
|
19 |
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
|
20 |
ENV C_INCLUDE_PATH=/usr/include/gdal
|
21 |
|
22 |
+
# Create a non-root user
|
23 |
+
RUN useradd -m -s /bin/bash appuser
|
24 |
+
|
25 |
# Copy the requirements file into the container
|
26 |
+
COPY requirements.txt .
|
27 |
|
28 |
# Install Python dependencies
|
29 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
30 |
+
pip install --no-cache-dir -r requirements.txt
|
31 |
+
|
32 |
+
# Copy the rest of the application code
|
33 |
+
COPY . .
|
34 |
+
|
35 |
+
# Change ownership of the /app directory to appuser
|
36 |
+
RUN chown -R appuser:appuser /app
|
37 |
+
|
38 |
+
# Switch to the non-root user
|
39 |
+
USER appuser
|
40 |
|
41 |
# Expose port 8501 for Streamlit
|
42 |
EXPOSE 8501
|