-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
135 lines (116 loc) · 4.98 KB
/
Containerfile
File metadata and controls
135 lines (116 loc) · 4.98 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
ARG BASE_VERSION=15
FROM ghcr.io/daemonless/base:${BASE_VERSION} AS builder
ENV MAKEFLAGS="-j2" \
CARGO_BUILD_JOBS=2 \
UV_CONCURRENCY=2 \
CC="/usr/bin/clang" \
CXX="/usr/bin/clang++"
# Build dependencies
RUN pkg update && \
pkg install -y \
python314 \
uv \
rust \
git-lite \
FreeBSD-clang \
FreeBSD-clang-dev \
FreeBSD-toolchain \
FreeBSD-clibs-dev \
FreeBSD-audit-dev \
FreeBSD-libexecinfo-dev \
FreeBSD-runtime-dev \
FreeBSD-utilities-dev \
FreeBSD-openssl-dev \
FreeBSD-zlib-dev \
ffmpeg-nox11 \
libffi \
libjpeg-turbo \
zlib-ng \
ca_root_nss \
zstd \
cmake \
ninja \
gcc \
autoconf \
automake \
libtool \
gmake \
pkgconf \
unzip && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/* && \
ln -s /usr/local/bin/gmake /usr/local/bin/make
# Fetch go2rtc FreeBSD binary
RUN GO2RTC_VERSION=$(fetch -qo - "https://api.github.com/repos/AlexxIT/go2rtc/releases/latest" | \
sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p') && \
fetch -o /tmp/go2rtc.zip \
"https://github.com/AlexxIT/go2rtc/releases/download/${GO2RTC_VERSION}/go2rtc_freebsd_amd64.zip" && \
unzip -o /tmp/go2rtc.zip go2rtc -d /usr/local/bin/ && \
chmod +x /usr/local/bin/go2rtc && \
rm /tmp/go2rtc.zip
# Create venv and install HA using full source for correct requirement resolution
RUN uv venv --python 3.14 /opt/hass && \
uv pip install --python /opt/hass homeassistant zlib-ng numpy==2.3.2
RUN VERSION=$(/opt/hass/bin/python -c "import homeassistant.const; print(homeassistant.const.__version__)") && \
git clone --depth 1 -b "$VERSION" https://github.com/home-assistant/core.git /tmp/ha-core && \
grep -v '^#' /tmp/ha-core/requirements_all.txt | grep -v '^$' > /tmp/reqs.txt && \
while read -r req; do \
uv pip install --python /opt/hass "$req" || echo "Skipping $req (build failed)"; \
done < /tmp/reqs.txt && \
rm -rf /tmp/ha-core /tmp/reqs.txt && \
rm -rf /root/.cargo /root/.cache
# Apply FreeBSD-specific patches
RUN sed -i '' 's/if not sys.platform.startswith(("darwin", "linux")):/if False:/' /opt/hass/lib/python3.14/site-packages/homeassistant/__main__.py && \
sed -i '' 's/except AuthError as ex:/except Exception as ex:/' /opt/hass/lib/python3.14/site-packages/bluetooth_adapters/dbus.py && \
sed -i '' 's/for adapter in self._bluez.adapter_details:/if False: # FreeBSD: no BlueZ/' /opt/hass/lib/python3.14/site-packages/bluetooth_adapters/systems/linux.py && \
rm -rf /root/.cache /root/.local/share/uv
# Capture installed version
RUN mkdir -p /app && \
/opt/hass/bin/python -c \
"import homeassistant.const; print(homeassistant.const.__version__)" \
> /app/version
# Production image
FROM ghcr.io/daemonless/base:${BASE_VERSION}
ARG FREEBSD_ARCH=amd64
ARG PACKAGES="python314 py314-sqlite3 ffmpeg-nox11 libffi libjpeg-turbo ca_root_nss pkgconf gmake cmake rust zlib-ng FreeBSD-clang FreeBSD-toolchain FreeBSD-clibs-dev FreeBSD-runtime-dev FreeBSD-utilities-dev FreeBSD-openssl-dev FreeBSD-zlib-dev git-lite"
ARG UPSTREAM_URL="https://api.github.com/repos/home-assistant/core/releases/latest"
ARG UPSTREAM_JQ=".tag_name"
ARG HEALTHCHECK_ENDPOINT="http://localhost:8123/api/"
ENV HEALTHCHECK_URL="${HEALTHCHECK_ENDPOINT}"
LABEL org.opencontainers.image.title="Home Assistant" \
org.opencontainers.image.description="Home Assistant on FreeBSD." \
org.opencontainers.image.source="https://github.com/daemonless/home-assistant" \
org.opencontainers.image.url="https://www.home-assistant.io/" \
org.opencontainers.image.documentation="https://www.home-assistant.io/docs/" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Utilities" \
io.daemonless.volumes="/config" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.upstream-url="${UPSTREAM_URL}" \
io.daemonless.upstream-jq="${UPSTREAM_JQ}" \
io.daemonless.healthcheck-url="${HEALTHCHECK_ENDPOINT}" \
io.daemonless.packages="${PACKAGES}"
RUN pkg update && \
pkg install -y ${PACKAGES} && \
ln -s /usr/local/bin/gmake /usr/local/bin/make && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
COPY --from=builder /opt/hass /opt/hass
COPY --from=builder /app/version /app/version
COPY --from=builder /usr/local/bin/go2rtc /usr/local/bin/go2rtc
RUN touch /.dockerenv && \
mkdir -p /config && \
chown -R bsd:bsd /config /opt/hass
COPY root/ /
RUN chmod +x /etc/services.d/home-assistant/run /healthz 2>/dev/null || true
ENV PATH="/opt/hass/bin:$PATH" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
VOLUME /config