Spaces:
Build error
Build error
T-K-O-H
commited on
Commit
·
fa43227
1
Parent(s):
96520ef
Update Dockerfile to use non-root user and fix permissions
Browse files- Dockerfile +11 -0
Dockerfile
CHANGED
|
@@ -9,6 +9,9 @@ RUN apt-get update && apt-get install -y \
|
|
| 9 |
software-properties-common \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
|
|
|
|
|
|
|
|
|
| 12 |
# Copy requirements first for better caching
|
| 13 |
COPY requirements.txt /code/requirements.txt
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
@@ -16,10 +19,18 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 16 |
# Copy the rest of the application
|
| 17 |
COPY . /code/
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Set environment variables
|
| 20 |
ENV HOST=0.0.0.0
|
| 21 |
ENV PORT=7860
|
| 22 |
ENV PYTHONPATH=/code
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# Command to run the application
|
| 25 |
CMD chainlit run app.py --host $HOST --port $PORT
|
|
|
|
| 9 |
software-properties-common \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Create a non-root user
|
| 13 |
+
RUN useradd -m -u 1000 chainlit_user
|
| 14 |
+
|
| 15 |
# Copy requirements first for better caching
|
| 16 |
COPY requirements.txt /code/requirements.txt
|
| 17 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 19 |
# Copy the rest of the application
|
| 20 |
COPY . /code/
|
| 21 |
|
| 22 |
+
# Create necessary directories and set permissions
|
| 23 |
+
RUN mkdir -p /code/.files && \
|
| 24 |
+
chown -R chainlit_user:chainlit_user /code && \
|
| 25 |
+
chmod -R 755 /code
|
| 26 |
+
|
| 27 |
# Set environment variables
|
| 28 |
ENV HOST=0.0.0.0
|
| 29 |
ENV PORT=7860
|
| 30 |
ENV PYTHONPATH=/code
|
| 31 |
|
| 32 |
+
# Switch to non-root user
|
| 33 |
+
USER chainlit_user
|
| 34 |
+
|
| 35 |
# Command to run the application
|
| 36 |
CMD chainlit run app.py --host $HOST --port $PORT
|