This commit is contained in:
Mateusz Gruszczyński
2026-09-16 22:38:45 +02:00
parent bb39ab9dfa
commit e02557bb65
15 changed files with 136 additions and 55 deletions
+51 -13
View File
@@ -1,29 +1,67 @@
# syntax=docker/dockerfile:1.7
ARG RUST_VERSION=1.89
ARG XX_VERSION=1.9.0
FROM --platform=$TARGETPLATFORM rust:${RUST_VERSION}-trixie AS builder-trixie
# Cross-compilation helpers. Builder stages always run on BUILDPLATFORM, so an
# amd64 host can compile arm64 without running rustc/cargo under QEMU.
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-trixie AS builder-trixie
COPY --from=xx / /
WORKDIR /src
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential pkg-config \
&& rm -rf /var/lib/apt/lists/*
COPY Cargo.toml Cargo.lock build.rs ./
&& apt-get install -y --no-install-recommends clang lld llvm file pkg-config
ARG TARGETPLATFORM
RUN xx-apt-get update \
&& xx-apt-get install -y --no-install-recommends xx-c-essentials \
&& rm -rf /var/lib/apt/lists/* \
&& xx-cargo --version >/dev/null
COPY Cargo.toml Cargo.lock ./
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
cargo fetch --locked
COPY build.rs ./
COPY src ./src
COPY web ./web
COPY lang ./lang
COPY presets ./presets
COPY docs ./docs
RUN cargo build --locked --release
COPY docs/openapi.json ./docs/openapi.json
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
--mount=type=cache,id=gree-controller-target-trixie,target=/src/target \
set -eux; \
xx-cargo build --locked --release --target-dir /src/target; \
binary="/src/target/$(xx-cargo --print-target-triple)/release/gree-controller"; \
xx-verify "$binary"; \
mkdir -p /out; \
cp "$binary" /out/gree-controller
FROM --platform=$TARGETPLATFORM rust:${RUST_VERSION}-alpine AS builder-alpine
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-alpine AS builder-alpine
COPY --from=xx / /
WORKDIR /src
RUN apk add --no-cache build-base pkgconfig musl-dev
COPY Cargo.toml Cargo.lock build.rs ./
RUN apk add --no-cache clang lld llvm file pkgconf
ARG TARGETPLATFORM
RUN xx-apk add --no-cache xx-c-essentials \
&& xx-cargo --version >/dev/null
COPY Cargo.toml Cargo.lock ./
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
cargo fetch --locked
COPY build.rs ./
COPY src ./src
COPY web ./web
COPY lang ./lang
COPY presets ./presets
COPY docs ./docs
RUN cargo build --locked --release
COPY docs/openapi.json ./docs/openapi.json
RUN --mount=type=cache,id=gree-controller-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=gree-controller-cargo-git,target=/usr/local/cargo/git \
--mount=type=cache,id=gree-controller-target-alpine,target=/src/target \
set -eux; \
xx-cargo build --locked --release --target-dir /src/target; \
binary="/src/target/$(xx-cargo --print-target-triple)/release/gree-controller"; \
xx-verify "$binary"; \
mkdir -p /out; \
cp "$binary" /out/gree-controller
FROM --platform=$TARGETPLATFORM debian:trixie-slim AS runtime-trixie
ARG BUILD_VERSION=dev
@@ -39,7 +77,7 @@ LABEL io.hass.version="${BUILD_VERSION}" \
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates tzdata jq iproute2 curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder-trixie /src/target/release/gree-controller /usr/local/bin/gree-controller
COPY --from=builder-trixie /out/gree-controller /usr/local/bin/gree-controller
COPY ha-addon/run.sh /usr/local/bin/run.sh
RUN chmod 0755 /usr/local/bin/run.sh /usr/local/bin/gree-controller
EXPOSE 8787/tcp
@@ -57,7 +95,7 @@ LABEL io.hass.version="${BUILD_VERSION}" \
org.opencontainers.image.version="${BUILD_VERSION}" \
org.opencontainers.image.architecture="${TARGETARCH}"
RUN apk add --no-cache ca-certificates tzdata jq iproute2 curl
COPY --from=builder-alpine /src/target/release/gree-controller /usr/local/bin/gree-controller
COPY --from=builder-alpine /out/gree-controller /usr/local/bin/gree-controller
COPY ha-addon/run.sh /usr/local/bin/run.sh
RUN chmod 0755 /usr/local/bin/run.sh /usr/local/bin/gree-controller
EXPOSE 8787/tcp
+2
View File
@@ -44,6 +44,8 @@ The project version comes only from root `Cargo.toml`. `render` synchronizes it
For the Home Assistant package, TCP `8787` is an intentional fixed host-network/ingress port contract. `build.sh render` verifies `config.yaml`, `run.sh`, the watchdog URL and Docker image metadata stay consistent. The runtime also compares the Supervisor-reported ingress port before starting. Standalone installations remain free to use any `GREE_CONTROLLER_BIND` port.
`DISTRO` still selects the target image system: `alpine` builds a musl binary for Alpine and `trixie` builds a GNU/glibc binary for Debian Trixie. Multi-architecture builds continue to run through `build.sh`; the Docker builder cross-compiles Rust on `BUILDPLATFORM` so ARM compilation does not run under QEMU, and BuildKit cache mounts preserve Cargo downloads and target artifacts between builds.
## Home Assistant repository
```bash
@@ -1,7 +1,7 @@
{
"domain": "gree_controller",
"name": "GREE Controller",
"version": "0.14.18",
"version": "0.14.19",
"config_flow": true,
"integration_type": "hub",
"iot_class": "local_polling",
@@ -1,5 +1,13 @@
# Changelog
## 0.14.19
- Speeds up multi-architecture OCI builds by running Rust/Cargo on `BUILDPLATFORM` and cross-compiling to amd64/arm64 instead of compiling ARM under QEMU.
- Keeps `DISTRO=alpine` as a musl/Alpine target and `DISTRO=trixie` as a GNU/glibc Debian Trixie target; `build.sh` remains the build entry point.
- Adds persistent BuildKit caches for Cargo registry/git data and compiled target artifacts; target Rust/C toolchains are prepared before project manifests so normal version/source changes keep the cross-toolchain layer cached.
- Reduces Docker build context and avoids invalidating Rust compilation for unrelated documentation/repository changes; only `docs/openapi.json` is copied because it is embedded by the binary.
- Deduplicates `/api/integrations/gree-cloud/status` across the initial HTTP bootstrap and immediate WebSocket bootstrap render while keeping manual Cloud reconnect refreshes forced.
## 0.14.18
- Renames the shared segmented navigation class from feature-specific `automation-tabs` to generic `segmented-tabs`.
@@ -1,5 +1,5 @@
name: "GREE Controller"
version: "0.14.18"
version: "0.14.19"
slug: "gree_controller"
description: "Local GREE HVAC controller with Web UI and Home Assistant integration"
url: "https://git.linuxiarz.pl/gru/gree-controller-ha-addon/"