-
Notifications
You must be signed in to change notification settings - Fork 124
/
Dockerfile
47 lines (34 loc) · 1.09 KB
/
Dockerfile
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
# Build stage
FROM python:3.12-slim AS builder
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libc6-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy only the requirements file first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Final stage
FROM python:3.12-slim
# Install curl for the healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends \
curl && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy installed dependencies from builder stage
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY . .
# Create a non-root user and switch to it
RUN useradd -m appuser
USER appuser
# Set environment variables
ENV PYTHONUNBUFFERED=1
# Expose the port the app runs on
EXPOSE 8000
# Run the application
ENTRYPOINT ["python", "optillm.py"]