-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
52 lines (42 loc) · 1.71 KB
/
Dockerfile.dev
File metadata and controls
52 lines (42 loc) · 1.71 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
# Optimized dev Dockerfile with persistent venv
FROM python:3.11-slim
# Workdir and environment
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_INPUT=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Install system dependencies (cached layer)
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment (will be mounted as volume in compose)
RUN python -m venv /app/.venv
# Copy only requirements for pip install layer (cached by BuildKit)
COPY requirements.txt /app/requirements.txt
COPY requirements-dev.txt /app/requirements-dev.txt
# Install Python dependencies with pip caching
# Note: If venv exists in volume mount, pip will skip already-installed packages
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
pip install --upgrade pip setuptools wheel && \
pip install -r /app/requirements.txt -r /app/requirements-dev.txt
# Copy application code
COPY . /app
# Create app user for non-root execution
RUN useradd --create-home --shell /bin/bash app || true && \
chown -R app:app /app && \
mkdir -p /app/.pytest_cache && \
chmod -R 755 /app/.pytest_cache
USER app
# Health check
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Start uvicorn with reload for development
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]