add Dockerfile arg to override optional Python dependencies to install at build time

This commit is contained in:
David Jimenez 2026-07-08 22:15:11 +01:00 committed by Xubin Ren
parent 4137be62a1
commit 6313ae9f4f

View File

@ -17,15 +17,16 @@ WORKDIR /app
# Install Python dependencies first (cached layer). Hatch reads the custom build # Install Python dependencies first (cached layer). Hatch reads the custom build
# hook from hatch_build.py even for this metadata-only install. # hook from hatch_build.py even for this metadata-only install.
ARG NANOBOT_EXTRAS=whatsapp
COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md hatch_build.py ./ COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md hatch_build.py ./
RUN mkdir -p nanobot && touch nanobot/__init__.py && \ RUN mkdir -p nanobot && touch nanobot/__init__.py && \
NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install --system --no-cache ".[whatsapp]" && \ NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install --system --no-cache ".[$NANOBOT_EXTRAS]" && \
rm -rf nanobot rm -rf nanobot
# Copy the full source and install # Copy the full source and install
COPY nanobot/ nanobot/ COPY nanobot/ nanobot/
COPY --from=webui-builder /app/nanobot/web/dist/ nanobot/web/dist/ COPY --from=webui-builder /app/nanobot/web/dist/ nanobot/web/dist/
RUN NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install --system --no-cache ".[whatsapp]" RUN NANOBOT_SKIP_WEBUI_BUILD=1 uv pip install --system --no-cache ".[$NANOBOT_EXTRAS]"
# Create non-root user and config directory # Create non-root user and config directory
RUN useradd -m -u 1000 -s /bin/bash nanobot && \ RUN useradd -m -u 1000 -s /bin/bash nanobot && \