-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (40 loc) · 1.21 KB
/
Dockerfile
File metadata and controls
56 lines (40 loc) · 1.21 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
# Multi-stage Dockerfile for MLOps Applications
# Optimized for production deployment
# Base stage with Python
FROM python:3.11-slim as base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Dependencies stage
FROM base as dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Development stage
FROM dependencies as development
COPY . .
# Expose ports for various services
EXPOSE 7860 8501 5000 8000
CMD ["bash"]
# Production stage
FROM dependencies as production
# Create non-root user
RUN useradd -m -u 1000 mlops && \
chown -R mlops:mlops /app
USER mlops
# Copy application code
COPY --chown=mlops:mlops . .
# Health check (optional - uncomment if you have a health endpoint)
# HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
# CMD curl -f http://localhost:8000/health || exit 1
# Default command - starts a bash shell
# Override this command when running specific services
CMD ["bash"]