-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (56 loc) · 1.68 KB
/
Copy pathDockerfile
File metadata and controls
75 lines (56 loc) · 1.68 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
63
64
65
66
67
68
69
70
71
72
73
74
75
# Multi-stage Dockerfile for DagLab
# Stage 1: Build stage
FROM python:3.11-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy only requirements first for better caching
COPY pyproject.toml setup.py ./
COPY src/daglab/__init__.py src/daglab/
# Install dependencies
RUN pip install --upgrade pip setuptools wheel && \
pip wheel --no-cache-dir --no-deps --wheel-dir /wheels .
# Copy the rest of the source code
COPY . .
# Build the wheel
RUN python -m build --wheel --outdir /wheels
# Stage 2: Runtime 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/*
# Create non-root user
RUN useradd -m -u 1000 daglab
# Set working directory
WORKDIR /app
# Copy wheels from builder
COPY --from=builder /wheels /wheels
# Install DagLab and dependencies
RUN pip install --upgrade pip && \
pip install --no-cache-dir --find-links /wheels daglab[all] && \
rm -rf /wheels
# Copy configuration files
COPY config /app/config
# Create necessary directories
RUN mkdir -p /app/data /app/logs && \
chown -R daglab:daglab /app
# Switch to non-root user
USER daglab
# Environment variables
ENV PYTHONUNBUFFERED=1 \
DAGLAB_CONFIG_PATH=/app/config/daglab.yaml \
DAGLAB_DATA_PATH=/app/data \
DAGLAB_LOG_PATH=/app/logs
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Expose ports
EXPOSE 8000
# Default command
CMD ["python", "-m", "daglab.server"]