-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.azure
More file actions
60 lines (45 loc) · 1.42 KB
/
Dockerfile.azure
File metadata and controls
60 lines (45 loc) · 1.42 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
56
57
58
59
60
# Azure-optimized Dockerfile for production deployment
FROM python:3.11-slim as builder
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Final stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libpq5 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy Python packages from builder stage
COPY --from=builder /root/.local /root/.local
# Update PATH to include user packages
ENV PATH=/root/.local/bin:$PATH
# Copy application code
COPY src/ ./src/
COPY data/ ./data/
COPY models/ ./models/
# Create necessary directories
RUN mkdir -p monitoring mlruns
# Set environment variables for Azure
ENV PYTHONPATH=/app
ENV MLFLOW_TRACKING_URI=sqlite:///mlflow.db
ENV PYTHONUNBUFFERED=1
# Azure Web App expects PORT environment variable
ENV PORT=8000
# Expose port
EXPOSE $PORT
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:$PORT/health || exit 1
# Run the application (Azure Web App will override this with its own command)
CMD ["python", "-m", "uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "8000"]