-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.dev
More file actions
62 lines (53 loc) · 2.29 KB
/
Dockerfile.dev
File metadata and controls
62 lines (53 loc) · 2.29 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
# Development Dockerfile - live reload with mounted source code
# Usage: make dev-docker (uses docker-compose.yml + docker-compose.dev.yml)
#
# The host's ./backend is mounted at /app/backend, but the host .venv
# (built for macOS/Windows) is incompatible with the Linux container.
# We use an anonymous volume for .venv and always install on first start.
FROM python:3.12-slim
# System deps
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential libpq-dev libxml2-dev libxslt1-dev curl && \
rm -rf /var/lib/apt/lists/*
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app/backend
# Add venv to PATH so uvicorn, celery, watchmedo are found
ENV PATH="/app/backend/.venv/bin:$PATH"
ENV PYTHONPATH="/app/backend"
ENV UV_LINK_MODE=copy
# Create entrypoint that always ensures deps are installed for Linux.
# The host .venv may be macOS-native and won't work here.
# We check if python in .venv actually runs (not just exists).
COPY <<'ENTRYPOINT' /entrypoint.sh
#!/bin/sh
set -e
# Check if the venv has a working Python (catches cross-platform mismatch)
if ! /app/backend/.venv/bin/python -c "import sys" 2>/dev/null; then
echo "[dev-entrypoint] Installing dependencies (venv missing or incompatible)..."
# Docker named volumes can't always be rm -rf'd, so try rm first and warn if it fails
rm_err_file="$(mktemp)"
if ! rm -rf /app/backend/.venv 2>"$rm_err_file"; then
echo "[dev-entrypoint] Warning: failed to remove /app/backend/.venv; continuing with 'uv venv --clear'." >&2
cat "$rm_err_file" >&2
fi
rm -f "$rm_err_file"
cd /app/backend && uv venv --clear && uv sync && uv pip install "watchdog[watchmedo]"
echo "[dev-entrypoint] Dependencies installed."
else
# Venv works — run uv sync to pick up any new/changed dependencies
echo "[dev-entrypoint] Syncing dependencies..."
if ! (cd /app/backend && uv sync --quiet); then
echo "[dev-entrypoint] Warning: dependency sync failed; continuing with existing environment." >&2
fi
# Ensure watchmedo is there too
if ! command -v watchmedo >/dev/null 2>&1; then
cd /app/backend && uv pip install "watchdog[watchmedo]"
fi
fi
exec "$@"
ENTRYPOINT
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 3000