Spaces:
Runtime error
Runtime error
T-K-O-H commited on
Commit ·
12852e9
1
Parent(s): 074216b
Update Dockerfile to fix permissions and run as non-root user
Browse files- Dockerfile +10 -2
Dockerfile
CHANGED
|
@@ -7,6 +7,9 @@ RUN apt-get update && apt-get install -y \
|
|
| 7 |
build-essential \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
# Copy requirements first to leverage Docker cache
|
| 11 |
COPY requirements.txt .
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
@@ -14,12 +17,17 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 14 |
# Copy the rest of the application
|
| 15 |
COPY . .
|
| 16 |
|
| 17 |
-
# Create necessary directories
|
| 18 |
-
RUN mkdir -p data/uploads
|
|
|
|
| 19 |
|
| 20 |
# Set environment variables
|
| 21 |
ENV PYTHONPATH=/app
|
| 22 |
ENV CHAINLIT_SERVER_PORT=8000
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Expose the port
|
| 25 |
EXPOSE 8000
|
|
|
|
| 7 |
build-essential \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Create a non-root user
|
| 11 |
+
RUN useradd -m -u 1000 chainlit_user
|
| 12 |
+
|
| 13 |
# Copy requirements first to leverage Docker cache
|
| 14 |
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
| 17 |
# Copy the rest of the application
|
| 18 |
COPY . .
|
| 19 |
|
| 20 |
+
# Create necessary directories and set permissions
|
| 21 |
+
RUN mkdir -p data/uploads .files && \
|
| 22 |
+
chown -R chainlit_user:chainlit_user /app
|
| 23 |
|
| 24 |
# Set environment variables
|
| 25 |
ENV PYTHONPATH=/app
|
| 26 |
ENV CHAINLIT_SERVER_PORT=8000
|
| 27 |
+
ENV HOME=/app
|
| 28 |
+
|
| 29 |
+
# Switch to non-root user
|
| 30 |
+
USER chainlit_user
|
| 31 |
|
| 32 |
# Expose the port
|
| 33 |
EXPOSE 8000
|