-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.35 KB
/
Dockerfile
File metadata and controls
51 lines (39 loc) · 1.35 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
# Build stage
FROM python:3.9-slim as builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy and install requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
&& find /usr/local -type d -name '*__pycache__*' -exec rm -r {} +
# Final stage
FROM python:3.9-slim
WORKDIR /app
# Copy only necessary Python packages from builder
COPY --from=builder /usr/local/lib/python3.9/site-packages/ /usr/local/lib/python3.9/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
# Install only runtime dependencies
RUN apt-get update && apt-get install -y \
libgomp1 \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app/data /app/chroma \
&& chmod -R 777 /app/data /app/chroma
# Copy application code and data
COPY data ./data/
COPY . .
# Create startup script
RUN echo '#!/bin/bash\n\
set -e\n\
echo "Starting database population..."\n\
python populate_database.py --reset\n\
echo "Database population complete. Starting web server..."\n\
gunicorn app.main:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --timeout 600 --bind 0.0.0.0:8000 --log-level debug --preload\n'\
> /app/startup.sh \
&& chmod +x /app/startup.sh
EXPOSE 8000
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
CMD ["/app/startup.sh"]