-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (34 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
47 lines (34 loc) · 1.11 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
# Multi-stage Dockerfile for Data Cellar connector healthcheck script
# Stage 1: Builder - Install dependencies
FROM python:3.11-slim AS builder
# Set working directory
WORKDIR /app
# Install uv for faster dependency resolution
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Set environment variables for Python optimization
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies into a virtual environment
RUN uv sync --frozen --no-dev --no-install-project
# Copy application code
COPY main.py ./
# Stage 2: Runtime - Minimal production image
FROM python:3.11-slim AS runtime
# Set working directory
WORKDIR /app
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH"
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application code
COPY main.py ./
# Set entrypoint to run the script
ENTRYPOINT ["python", "main.py"]
# Default command (can be overridden)
CMD ["--help"]