Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (44 loc) · 1.65 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (44 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app
ENV WATCHFILES_FORCE_POLLING=true
# Install system dependencies + SSL certificates
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
curl \
ca-certificates \
openssl \
&& update-ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy requirements and install Python dependencies with retry logic
COPY config/requirements.txt .
RUN pip install --no-cache-dir --timeout 300 --retries 5 -r requirements.txt || \
(echo "First attempt failed, retrying..." && \
pip install --no-cache-dir --timeout 600 --retries 10 -r requirements.txt) || \
(echo "Second attempt failed, retrying with different index..." && \
pip install --no-cache-dir --timeout 600 --retries 10 --index-url https://pypi.org/simple/ -r requirements.txt)
# Install development dependencies for auto-reload
RUN pip install --no-cache-dir watchfiles[watchdog] uvicorn[standard]
# Copy application code
COPY app/ ./app/
COPY config/ ./config/
COPY frontend/ ./frontend/
COPY main.py .
# Create necessary directories
RUN mkdir -p data cache results
# Create non-root user
RUN useradd --create-home --shell /bin/bash app && \
chown -R app:app /app
USER app
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Start the application (reload controlled via env var)
CMD ["bash", "-c", "uvicorn app.api.app:app --host 0.0.0.0 --port 8000 ${UVICORN_RELOAD:+--reload}"]