-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·62 lines (49 loc) · 1.44 KB
/
Dockerfile
File metadata and controls
executable file
·62 lines (49 loc) · 1.44 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
61
62
FROM python:3.11-slim
# Set metadata
LABEL maintainer="MLOps Team"
LABEL description="MLOps Pipeline Application"
LABEL version="1.0"
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONPATH=/app
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Create non-root user for security
RUN groupadd -r mlops && useradd -r -g mlops mlops
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create necessary directories with proper permissions
RUN mkdir -p artifacts/model_trainer \
artifacts/data_transformation \
artifacts/data_validation \
artifacts/feature_engineering \
artifacts/model_evaluation \
artifacts/data_ingestion \
logs \
static \
templates && \
chown -R mlops:mlops /app
# Switch to non-root user
USER mlops
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1
# Run the application
CMD ["python", "app.py"]