Enhance Dockerfile with verbose output for system dependency installation and improved logging during setup
Browse files- Dockerfile +24 -13
Dockerfile
CHANGED
|
@@ -2,21 +2,30 @@ FROM python:3.9-slim
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system dependencies
|
| 6 |
-
RUN
|
|
|
|
|
|
|
| 7 |
build-essential \
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Create directories with secure permissions
|
| 11 |
-
RUN
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Copy requirements first for better caching
|
| 16 |
COPY requirements.txt .
|
| 17 |
-
RUN
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
# Copy
|
| 20 |
COPY app.py .
|
| 21 |
COPY .env .
|
| 22 |
COPY index.html .
|
|
@@ -28,9 +37,11 @@ ENV XDG_CACHE_HOME=/app/cache
|
|
| 28 |
ENV PORT=8000
|
| 29 |
|
| 30 |
# Set permissions
|
| 31 |
-
RUN
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Run as non-privileged user
|
| 36 |
USER 1000
|
|
@@ -41,5 +52,5 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
|
| 41 |
|
| 42 |
EXPOSE 8000
|
| 43 |
|
| 44 |
-
# Use a startup script
|
| 45 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install system dependencies with verbose output
|
| 6 |
+
RUN set -x && \
|
| 7 |
+
apt-get update && \
|
| 8 |
+
apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
+
curl \
|
| 11 |
+
git \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 13 |
+
&& echo "System dependencies installed successfully"
|
| 14 |
|
| 15 |
# Create directories with secure permissions
|
| 16 |
+
RUN set -x && \
|
| 17 |
+
mkdir -p cache/huggingface vector_store chat_history && \
|
| 18 |
+
chown -R 1000:1000 . && \
|
| 19 |
+
chmod -R 755 . && \
|
| 20 |
+
echo "Directories created successfully"
|
| 21 |
|
| 22 |
# Copy requirements first for better caching
|
| 23 |
COPY requirements.txt .
|
| 24 |
+
RUN set -x && \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt && \
|
| 26 |
+
echo "Python dependencies installed successfully"
|
| 27 |
|
| 28 |
+
# Copy application files
|
| 29 |
COPY app.py .
|
| 30 |
COPY .env .
|
| 31 |
COPY index.html .
|
|
|
|
| 37 |
ENV PORT=8000
|
| 38 |
|
| 39 |
# Set permissions
|
| 40 |
+
RUN set -x && \
|
| 41 |
+
chown -R 1000:1000 /app && \
|
| 42 |
+
find /app -type d -exec chmod 755 {} \; && \
|
| 43 |
+
find /app -type f -exec chmod 644 {} \; && \
|
| 44 |
+
echo "Permissions set successfully"
|
| 45 |
|
| 46 |
# Run as non-privileged user
|
| 47 |
USER 1000
|
|
|
|
| 52 |
|
| 53 |
EXPOSE 8000
|
| 54 |
|
| 55 |
+
# Use a startup script with debug output
|
| 56 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "debug"]
|