adaptive-lighting/Dockerfile
Bas Nijholt d07f5813a9 Fix Docker volume mounts overwriting build-time symlinks
Move pytest command to entrypoint script that recreates symlinks at
runtime. This allows mounting local code with -v without breaking the
symlinks that connect the test runner to the component and test files.
2026-01-11 12:44:45 -08:00

42 lines
1.3 KiB
Docker

# See tests/README.md for instructions on how to run the tests.
# tl;dr:
# Run the following command in the adaptive-lighting repo folder to run the tests:
# docker run -v $(pwd):/app basnijholt/adaptive-lighting:latest
# Optionally build the image yourself with:
# docker build -t basnijholt/adaptive-lighting:latest .
FROM ghcr.io/astral-sh/uv:debian
# Install build dependencies for Python extensions
RUN apt-get update && apt-get install -y --no-install-recommends \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Clone home-assistant/core
RUN git clone --depth 1 --branch dev https://github.com/home-assistant/core.git /core
# Copy the Adaptive Lighting repository
COPY . /app/
# Setup symlinks in core
RUN ln -s /core /app/core && /app/scripts/setup-symlinks
# Install home-assistant/core dependencies
RUN mkdir -p /.venv
ENV UV_PROJECT_ENVIRONMENT=/.venv UV_PYTHON=3.13 PATH="/.venv/bin:$PATH"
RUN uv venv
RUN /app/scripts/setup-dependencies
WORKDIR /app/core
# Make 'custom_components/adaptive_lighting' imports available to tests
ENV PYTHONPATH="${PYTHONPATH}:/app"
# Entrypoint sets up symlinks at runtime (needed because volume mount overwrites build-time symlinks)
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
# Run tests in the 'tests/components/adaptive_lighting' directory
CMD ["tests/components/adaptive_lighting"]