Building home-assistant/frontend #3
|
@ -1,4 +1,5 @@
|
|||
core/
|
||||
frontend/
|
||||
dist/*
|
||||
target/*
|
||||
mount/
|
||||
|
|
|
@ -1,18 +1,47 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
dir=$(dirname $0)
|
||||
HASS_MAIN_BRANCH=dev
|
||||
|
||||
if [[ ! -d core/ ]]; then
|
||||
$dir/.pipeline/git-init.sh
|
||||
echo "[>] git-init.sh"
|
||||
$dir/git-init.sh
|
||||
else
|
||||
echo "[ ] exists: 'core/'"
|
||||
echo "[>] git checkout $HASS_MAIN_BRANCH"
|
||||
git -C core/ checkout $HASS_MAIN_BRANCH
|
||||
fi
|
||||
|
||||
if [[ "$HASS_VERSION" == "" ]]; then
|
||||
HASS_VERSION=$($dir/version.sh)
|
||||
echo "[>] version.sh"
|
||||
source $dir/version.sh
|
||||
fi
|
||||
|
||||
docker build -t hass:${HASS_VERSION} .
|
||||
echo "[ ] HASS_VERSION: '$HASS_VERSION'"
|
||||
echo "[>] git-checkout-version.sh"
|
||||
$dir/git-checkout-version.sh
|
||||
|
||||
docker image ls hass:${HASS_VERSION}
|
||||
echo "[>] docker build"
|
||||
# --target export --output dist/
|
||||
docker build \
|
||||
--progress plain \
|
||||
-t hass:latest \
|
||||
.
|
||||
|
||||
docker tag hass:${HASS_VERSION} git.sudo.is/ben/hass:${HASS_VERSION}
|
||||
echo "[>] docker tag"
|
||||
docker tag hass:latest hass:${HASS_VERSION}
|
||||
docker tag hass:${HASS_VERSION} git.sudo.is/ben/hass:latest
|
||||
docker tag hass:${HASS_VERSION} git.sudo.is/ben/hass:${HASS_VERSION}
|
||||
|
||||
echo "[ ] docker image ls hass"
|
||||
docker image ls hass
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
# run docker container with -t if we are in a TTY
|
||||
DOCKER_OPT_TTY="-t"
|
||||
fi
|
||||
|
||||
echo "[ ] docker run hass:latest --version"
|
||||
docker run --rm $DOCKER_OPT_TTY hass:latest --version
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
HASS_REPO="core"
|
||||
else
|
||||
HASS_REPO="$1"
|
||||
fi
|
||||
|
||||
# Disable the warning about what wre about to do
|
||||
|
||||
# The GIT_CONFIG_PARAMETERS env var can't _start_ with a space, then
|
||||
|
@ -18,10 +24,10 @@ export GIT_CONFIG_PARAMETERS
|
|||
|
||||
# Another way to do this is with 'git config', which does edit the .git/config
|
||||
# file of the repo.
|
||||
#git -C core/ config --worktree advice.detachedHead false
|
||||
#git -C ${HASS_REPO}/ config --worktree advice.detachedHead false
|
||||
|
||||
# check out the tag for the version we building (probably the latest version)
|
||||
git -C core/ checkout $HASS_VERSION
|
||||
git -C ${HASS_REPO}/ checkout $HASS_VERSION
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
|
||||
set -e
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
HASS_REPO="core"
|
||||
else
|
||||
HASS_REPO="$1"
|
||||
fi
|
||||
|
||||
if [[ "${USE_GITHUB}" != "true" ]]; then
|
||||
HASS_GIT_URL="https://git.sudo.is/home-assistant"
|
||||
else
|
||||
|
@ -12,27 +18,27 @@ HASS_MAIN_BRANCH="dev"
|
|||
LOCAL_PATH=$(git rev-parse --show-toplevel)
|
||||
|
||||
|
||||
if [[ ! -d "core/.git" ]]; then
|
||||
echo "cloning '$HASS_GIT_URL/core'... "
|
||||
git clone -q $HASS_GIT_URL/core
|
||||
if [[ ! -d "${HASS_REPO}/.git" ]]; then
|
||||
echo "cloning '$HASS_GIT_URL/${HASS_REPO}'... "
|
||||
git clone -q $HASS_GIT_URL/${HASS_REPO}
|
||||
echo "done"
|
||||
else
|
||||
git -C core/ checkout .
|
||||
git -C core/ clean -fd
|
||||
git -C ${HASS_REPO}/ checkout .
|
||||
git -C ${HASS_REPO}/ clean -fd
|
||||
|
||||
CURRENT_BRANCH=$(git -C core/ rev-parse --abbrev-ref HEAD)
|
||||
CURRENT_BRANCH=$(git -C ${HASS_REPO}/ rev-parse --abbrev-ref HEAD)
|
||||
if [[ "$CURRENT_BRANCH" != "${HASS_MAIN_BRANCH}" ]]; then
|
||||
git -C core/ checkout $HASS_MAIN_BRANCH
|
||||
git -C ${HASS_REPO}/ checkout $HASS_MAIN_BRANCH
|
||||
fi
|
||||
|
||||
git -C core/ remote rm origin || true
|
||||
git -C core/ remote add origin $HASS_GIT_URL/core
|
||||
git -C core/ pull origin $HASS_MAIN_BRANCH
|
||||
git -C ${HASS_REPO}/ remote rm origin || true
|
||||
git -C ${HASS_REPO}/ remote add origin $HASS_GIT_URL/${HASS_REPO}
|
||||
git -C ${HASS_REPO}/ pull origin $HASS_MAIN_BRANCH
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "HASS remote: '$HASS_GIT_URL/core'"
|
||||
echo "HASS local: '$LOCAL_PATH/core'"
|
||||
echo "HASS branch: '$(git -C core/ rev-parse --abbrev-ref HEAD)'"
|
||||
echo "HASS remote: '$HASS_GIT_URL/${HASS_REPO}'"
|
||||
echo "HASS local: '$LOCAL_PATH/${HASS_REPO}'"
|
||||
echo "HASS branch: '$(git -C ${HASS_REPO}/ rev-parse --abbrev-ref HEAD)'"
|
||||
echo
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
set -e
|
||||
|
||||
HASS_REPO="core"
|
||||
|
||||
# ALTERNATIVE: USE GITHUB API
|
||||
#
|
||||
# $ curl -s https://api.github.com/repos/home-assistant/core/releases/latest | jq .name
|
||||
|
@ -11,6 +9,17 @@ HASS_REPO="core"
|
|||
#
|
||||
# Open in Firefox, check the JSON. Lots of fields, and several fields with the version number.
|
||||
# DO NOT IGNORE.
|
||||
HASS_MAIN_BRANCH=dev
|
||||
if [[ -z "$1" ]]; then
|
||||
HASS_REPO="core"
|
||||
else
|
||||
HASS_REPO="$1"
|
||||
fi
|
||||
|
||||
PWD_REPO_NAME=$(basename $(git rev-parse --show-toplevel))
|
||||
if [[ "$PWD_REPO_NAME" != "${HASS_REPO}" ]]; then
|
||||
GIT_CHDIR_OPT="-C ${HASS_REPO}/"
|
||||
fi
|
||||
|
||||
if [[ -n "${HASS_VERSION}" ]]; then
|
||||
echo "environment var 'HASS_VERSION' is alrady set, this probably means that a specific/version tag is being built manually" >&2
|
||||
|
@ -19,18 +28,15 @@ if [[ -n "${HASS_VERSION}" ]]; then
|
|||
echo "will use this value and not look for tha latest git tag" >&2
|
||||
sleep 5
|
||||
else
|
||||
PWD_REPO_NAME=$(basename $(git rev-parse --show-toplevel))
|
||||
if [[ "$PWD_REPO_NAME" != "${HASS_REPO}" ]]; then
|
||||
GIT_CHDIR_OPT="-C ${HASS_REPO}/"
|
||||
fi
|
||||
git $GIT_CHDIR_OPT checkout $HASS_MAIN_BRANCH
|
||||
git $GIT_CHDIR_OPT fetch --tags
|
||||
LATEST_TAG=$(git $GIT_CHDIR_OPT describe --tags $(git $GIT_CHDIR_OPT rev-list --tags --max-count=1))
|
||||
#LATEST_TAG=$(git $GIT_CHDIR_OPT describe --tags $(git $GIT_CHDIR_OPT rev-list --tags --max-count=1))
|
||||
# gets all tags without sorting
|
||||
# git tag -l --sort=-creatordate | head -n 1
|
||||
# gets all tags
|
||||
#LATEST_TAG=$(git $GIT_CHDIR_OPT tag -l --sort=-creatordate | head -n 1)
|
||||
# gets annotated tags (releases)
|
||||
#LATEST_TAG=$(git $GIT_CHDIR_OPT describe --tags --abbrev=0)
|
||||
LATEST_TAG=$(git $GIT_CHDIR_OPT describe --tags --abbrev=0)
|
||||
HASS_VERSION=$LATEST_TAG
|
||||
# the version is also in pyproject.toml and homeassistant/setup.py (not 100% sure anout setup.py)
|
||||
# but that is the version of the current branch, not
|
||||
|
|
106
Dockerfile
106
Dockerfile
|
@ -11,11 +11,6 @@ ENV TERM=xterm-256color
|
|||
ARG HASS_UID=1229
|
||||
ARG HASS_GID=1229
|
||||
|
||||
# python:latest is debian -> glibc
|
||||
#ARG LIBC="gnu"
|
||||
# python:alpine -> musl
|
||||
#ARG LIBC="musl"
|
||||
|
||||
#COPY deb/deps.txt /tmp/deps.txt
|
||||
# xargs -a /tmp/deps.txt apt-get -y install && \
|
||||
RUN set -xe && \
|
||||
|
@ -46,12 +41,34 @@ RUN set -xe && \
|
|||
ffmpeg \
|
||||
nmap socat \
|
||||
dbus \
|
||||
jq && \
|
||||
echo apt-get install -y libjemalloc-dev libjemalloc2 && \
|
||||
jq tree \
|
||||
musl \
|
||||
libjemalloc2 && \
|
||||
apt-get clean && \
|
||||
apt-get autoclean
|
||||
|
||||
RUN set -x && apt-get -y install libjemalloc-dev tree
|
||||
# not needed:
|
||||
# - musl-dev
|
||||
# - libjemalloc-dev:
|
||||
# provides: libjemalloc.so (linked against gnu libc)
|
||||
|
||||
ARG HASS_VENV_PATH=/usr/local/src/core/.venv
|
||||
ENV HASS_VENV_PATH=${HASS_VENV_PATH}
|
||||
ENV PATH=${HASS_VENV_PATH}/bin:/var/lib/hass/.local/bin:${PATH}
|
||||
ENV VIRTUAL_ENV=${HASS_VENV_PATH}
|
||||
#ENV UV_SYSTEM_PYTHON=true
|
||||
|
||||
# this is not enough to switch from gnu libc to musl for building
|
||||
# python wheels or compiling C/C++ etc. for Rust it would not
|
||||
# even be needed.
|
||||
#
|
||||
# python:latest is debian -> glibc
|
||||
#ARG LIBC="gnu"
|
||||
# python:alpine -> musl
|
||||
#ARG LIBC="musl"
|
||||
|
||||
RUN set -x && \
|
||||
ld-musl-config
|
||||
|
||||
FROM base as builder
|
||||
RUN set -x && \
|
||||
|
@ -62,37 +79,53 @@ USER hass
|
|||
WORKDIR /usr/local/src/core
|
||||
RUN set -x && \
|
||||
pip install wheel uv && \
|
||||
/var/lib/hass/.local/bin/uv venv && \
|
||||
/var/lib/hass/.local/bin/uv venv ${HASS_VENV_PATH} && \
|
||||
mkdir homessistant
|
||||
|
||||
COPY --chown=hass:hass core/homeassistant/package_constraints.txt /usr/local/src/core/homeassistant/
|
||||
# core/requirements.txt: ~30 lines
|
||||
COPY --chown=hass:hass core/requirements.txt /usr/local/src/core/
|
||||
# core/requirements_all.txt: ~2800 lines
|
||||
COPY --chown=hass:hass core/requirements_all.txt /usr/local/src/core/
|
||||
#COPY docker/bin/build-requirements.sh /usr/local/bin/
|
||||
|
||||
# "use jemalloc" in builds: https://github.com/home-assistant/core/commit/e18a6e376cc6f4b0c818159bd83944e1ddd13f7f
|
||||
RUN set -e && \
|
||||
echo "LD_PRELOAD=$LD_PRELOAD" \
|
||||
[[ -n "$LD_PRELOAD" ]] $$ exit 1
|
||||
COPY docker/bin/muslick.sh /usr/local/bin/
|
||||
# For musl:
|
||||
#ENV LD_PRELOAD="/usr/local/lib/libjemalloc.so.2"
|
||||
# root@python3.12:/# find / -name "*libjemalloc*.so*"
|
||||
# /usr/lib/x86_64-linux-gnu/libjemalloc.so.2 # libjemalloc2
|
||||
# /usr/lib/x86_64-linux-gnu/libjemalloc.so # libjemalloc-dev
|
||||
#
|
||||
# root@python3.12:/# find / -name "*musl*.so*"
|
||||
# /usr/lib/ld-musl-x86_64.so.1
|
||||
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
|
||||
ENV MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:20000,muzzy_decay_ms:20000"
|
||||
# For libc:
|
||||
#ENV LD_PRELOAD="/usr/lib/${arch}-linux-gnu/libjemalloc.so.2"
|
||||
# see: docker/bin/build-requirements.sh
|
||||
RUN set -x && \
|
||||
/usr/local/bin/muslick.sh && \
|
||||
stat $LD_PRELOAD 1>/dev/null && \
|
||||
|
||||
# Here the upstream image also copies in wheels of frontend and intentions (we dont use intentions)
|
||||
# Not sure why they dont let frontend be installed from their wheel archive
|
||||
# 'home-assistant-frontend' is in core/requirements_all.txt (but not in core/requirements.txt)
|
||||
# The upstream docker container runs pip with '--no-index --only-binary=:all: --index-url https://wheels.home-assistant.io/musllinux-index'
|
||||
# which is built from the home-assistant/wheels repo.
|
||||
# Thats something to do in the future, but for now we'll install and compile source packages from PyPI.
|
||||
# Since are just building prod releases, and not PRs and etc, we are fine with
|
||||
# doing this in one step instead of first copying core/requirements.txt, building/installing
|
||||
# them, and then copyign core/requirements_all.txt as the upstream image does.
|
||||
# Doing it this way allows us to use build-requirements.sh and affords us more
|
||||
# flexibility, since for us it doesnt matter that we install them all in one layer.
|
||||
ARG HASS_VENV_PATH=/usr/local/src/core/.venv
|
||||
ENV PATH=${HASS_VENV_PATH}/bin:/var/lib/hass/.local/bin:${PATH}
|
||||
|
||||
# core/requirements.txt: ~30 lines
|
||||
COPY --chown=hass:hass core/requirements.txt /usr/local/src/core/
|
||||
COPY --chown=hass:hass core/homeassistant/package_constraints.txt /usr/local/src/core/homeassistant/
|
||||
# core/requirements_all.txt: ~2800 lines
|
||||
COPY --chown=hass:hass core/requirements_all.txt /usr/local/src/core/
|
||||
#COPY docker/bin/muslick.sh /usr/local/bin/
|
||||
#COPY docker/bin/build-requirements.sh /usr/local/bin/
|
||||
|
||||
# Here the upstream image also copies in wheels of frontend and intentions (we dont use intentions)
|
||||
# Not sure why they dont let frontend be installed from their wheel archive
|
||||
# 'home-assistatn-frontend' is in core/requirements_all.txt (but not in core/requirements.txt)
|
||||
# The upstream docker container runs pip with '--no-index --only-binary=:all: --index-url https://wheels.home-assistant.io/musllinux-index'
|
||||
# which is built from the home-assistant/wheels repo.
|
||||
# Thats something to do in the future, but for now we'll install and compile source packages from PyPI.
|
||||
RUN set -x && \
|
||||
uv pip install -r requirements.txt && \
|
||||
uv pip install -r requirements_all.txt
|
||||
|
||||
RUN set -x && \
|
||||
uv pip install -r requirements_all.txt && \
|
||||
du -sh /usr/local/src/core/.venv/ && \
|
||||
which python python3 pip uv
|
||||
|
||||
|
@ -110,15 +143,6 @@ RUN set -x && \
|
|||
# find /usr/local/src -name "*.whl" && \
|
||||
# pip cache dir
|
||||
|
||||
# "use jemalloc" in builds: https://github.com/home-assistant/core/commit/e18a6e376cc6f4b0c818159bd83944e1ddd13f7f
|
||||
|
||||
#ENV MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:20000,muzzy_decay_ms:20000"
|
||||
# For musl:
|
||||
#ENV LD_PRELOAD="/usr/local/lib/libjemalloc.so.2"
|
||||
# For libc:
|
||||
#ENV LD_PRELOAD="/usr/lib/${arch}-linux-gnu/libjemalloc.so.2"
|
||||
# see: docker/bin/build-requirements.sh
|
||||
|
||||
FROM base as packager
|
||||
RUN set -x && \
|
||||
apt-get install -y ruby ruby-dev rubygems && \
|
||||
|
@ -158,7 +182,9 @@ RUN set -x && \
|
|||
apt-get autoclean
|
||||
USER hass
|
||||
|
||||
COPY --from=builder --chown=hass:hass /usr/local/src/core/.venv/ /usr/local/src/core/.venv/
|
||||
ENV PATH "/usr/local/src/core/.venv/bin:$PATH"
|
||||
ENV PATH "${HASS_VENV_PATH}/bin:$PATH"
|
||||
COPY --from=builder --chown=hass:hass ${HASS_VENV_PATH} ${HASS_VENV_PATH}
|
||||
#COPY --chown=hass:hass rootfs/bin/frontend_path.py ${HASS_VENV_PATH}/bin/
|
||||
COPY --chown=hass:hass rootfs /usr/local/
|
||||
|
||||
ENTRYPOINT ["python3", "-m", "homeassistant", "--config", "/etc/hass"]
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh", "--config", "/etc/hass"]
|
||||
|
|
|
@ -31,6 +31,10 @@ pipeline {
|
|||
env.GITEA_USER = sh(script: "echo $GIT_URL | cut -d'/' -f4", returnStdout: true).trim()
|
||||
|
||||
env.HASS_GIT_URL = params.use_github ? "https://github.com/home-assistant/core" : "https://git.sudo.is/home-assistant/core"
|
||||
env.HASS_FRONTEND_GIT_URL = params.use_github ? "https://github.com/home-assistant/frontend" : "https://git.sudo.is/home-assistant/frontend"
|
||||
dir('frontend') {
|
||||
git(url: env.HASS_FRONTEND_GIT_URL, branch: env.HASS_MAIN_BRANCH)
|
||||
}
|
||||
dir('core') {
|
||||
git(url: env.HASS_GIT_URL, branch: env.HASS_MAIN_BRANCH)
|
||||
if (params.version != "") {
|
||||
|
@ -75,16 +79,11 @@ pipeline {
|
|||
//echo "hass: ${env.HASS_DEB}"
|
||||
}
|
||||
}
|
||||
stage('publish') {
|
||||
when {
|
||||
branch "b"
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh "env | grep hass"
|
||||
sh "sha256sum core/requirements_all.txt core/requirements.txt"
|
||||
}
|
||||
success {
|
||||
sh "ls --color=always -1 . ./dist/"
|
||||
sh "docker push git.sudo.is/ben/hass:${env.HASS_VERSION}"
|
||||
archiveArtifacts(artifacts: "dist/*.tar.gz,dist/*.deb,dist/*.zip,dist/hass_version.txt,dist/sha256sums.txt", fingerprint: true)
|
||||
steps {
|
||||
script {
|
||||
if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) {
|
||||
withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) {
|
||||
|
@ -104,6 +103,18 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh "env | grep hass"
|
||||
sh "sha256sum core/requirements_all.txt core/requirements.txt"
|
||||
}
|
||||
success {
|
||||
sh "ls --color=always -1 . ./dist/"
|
||||
sh "docker push git.sudo.is/ben/hass:${env.HASS_VERSION}"
|
||||
archiveArtifacts(artifacts: "dist/*.tar.gz,dist/*.deb,dist/*.zip,dist/hass_version.txt,dist/sha256sums.txt", fingerprint: true)
|
||||
}
|
||||
cleanup {
|
||||
cleanWs(deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true)
|
||||
sh "docker container rm hass-build || true"
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
/usr/local/bin/frontend_path.py
|
||||
which python3 hass
|
||||
|
||||
du -sh ${HASS_VENV_PATH} || true
|
||||
du -sh /usr/local
|
||||
|
||||
python3 -m homeassistant $@
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import hass_frontend
|
||||
|
||||
def frontend():
|
||||
# public/__init__.py
|
||||
# in frimtens repi
|
||||
return hass_frontend.where()
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = frontend()
|
||||
print(f)
|
Loading…
Reference in New Issue