Files
open-xiaoai/examples/hass/Dockerfile
T

54 lines
1.5 KiB
Docker
Raw Normal View History

FROM python:3.12-slim AS builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update && apt-get install -y --no-install-recommends \
curl build-essential pkg-config libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV BASH_ENV=/root/.bash_env
RUN touch "$BASH_ENV"
RUN echo '. "$BASH_ENV"' >> "$HOME/.bashrc"
RUN echo '[ -s "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"' >> "$BASH_ENV"
WORKDIR /app
COPY examples/hass/hass ./hass
COPY examples/hass/src ./src
COPY examples/hass/Cargo.toml ./Cargo.toml
COPY examples/hass/pyproject.toml ./pyproject.toml
COPY examples/hass/README.md ./README.md
COPY examples/hass/requirements.txt ./requirements.txt
COPY examples/hass/hass_assistant.py ./hass_assistant.py
COPY examples/hass/config.example.json ./config.example.json
COPY packages/client-rust ./client-rust
RUN python -m venv /opt/venv
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install maturin
RUN sed -i 's/\.\.\/\.\.\/packages\///g' Cargo.toml \
&& maturin develop --release
FROM python:3.12-slim
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="/opt/venv/bin:${PATH}"
WORKDIR /app
COPY --from=builder /opt/venv /opt/venv
COPY --from=builder /app/hass /app/hass
COPY --from=builder /app/hass_assistant.py /app/hass_assistant.py
COPY --from=builder /app/config.example.json /app/config.example.json
CMD ["python", "hass_assistant.py"]