From 5a6c8802f7962853d79eb1858ec8edc1a965d78c Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Mon, 1 Apr 2024 03:28:21 +0200 Subject: [PATCH 01/13] wip --- .pipeline/build.sh | 34 +++++++++++++--- .pipeline/git-checkout-version.sh | 10 ++++- .pipeline/git-init.sh | 32 +++++++++------ .pipeline/version.sh | 22 ++++++---- Dockerfile | 68 +++++++++++++++++++++---------- Jenkinsfile | 4 ++ rootfs/bin/entrypoint.sh | 10 +++++ rootfs/bin/frontend_path.py | 10 +++++ 8 files changed, 141 insertions(+), 49 deletions(-) create mode 100755 rootfs/bin/entrypoint.sh create mode 100755 rootfs/bin/frontend_path.py diff --git a/.pipeline/build.sh b/.pipeline/build.sh index 6095379..abe9fcf 100755 --- a/.pipeline/build.sh +++ b/.pipeline/build.sh @@ -1,18 +1,42 @@ #!/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 + +echo "[ ] docker run hass:latest --version" +docker run --rm -it hass:latest --version + + diff --git a/.pipeline/git-checkout-version.sh b/.pipeline/git-checkout-version.sh index 12c192b..cd0c588 100755 --- a/.pipeline/git-checkout-version.sh +++ b/.pipeline/git-checkout-version.sh @@ -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 diff --git a/.pipeline/git-init.sh b/.pipeline/git-init.sh index 2299781..8a476bd 100755 --- a/.pipeline/git-init.sh +++ b/.pipeline/git-init.sh @@ -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 diff --git a/.pipeline/version.sh b/.pipeline/version.sh index ed046c4..2f2e366 100755 --- a/.pipeline/version.sh +++ b/.pipeline/version.sh @@ -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 diff --git a/Dockerfile b/Dockerfile index e653cc2..999bfff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,12 +46,28 @@ 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. +RUN set -x && \ + ld-musl-config FROM base as builder RUN set -x && \ @@ -62,33 +78,50 @@ 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 +# "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 # 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} +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/ -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) +# '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. RUN set -x && \ + /usr/local/bin/muslick.sh && \ + stat $LD_PRELOAD 1>/dev/null && \ uv pip install -r requirements.txt && \ uv pip install -r requirements_all.txt @@ -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"] diff --git a/Jenkinsfile b/Jenkinsfile index f5dfc66..bc0a019 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 != "") { diff --git a/rootfs/bin/entrypoint.sh b/rootfs/bin/entrypoint.sh new file mode 100755 index 0000000..55ca783 --- /dev/null +++ b/rootfs/bin/entrypoint.sh @@ -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 $@ diff --git a/rootfs/bin/frontend_path.py b/rootfs/bin/frontend_path.py new file mode 100755 index 0000000..6c7b846 --- /dev/null +++ b/rootfs/bin/frontend_path.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +import hass_frontend + +def frontend(): + return hass_frontend.where() + +if __name__ == "__main__": + f = frontend() + print(f) -- 2.40.1 From d7fb914ac8389d79414a16305136b6bf63f84c41 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:09:26 +0200 Subject: [PATCH 02/13] docker tty opt --- .pipeline/build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.pipeline/build.sh b/.pipeline/build.sh index abe9fcf..234f5fd 100755 --- a/.pipeline/build.sh +++ b/.pipeline/build.sh @@ -36,7 +36,12 @@ 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 -it hass:latest --version +docker run --rm $DOCKER_OPT_TTY hass:latest --version -- 2.40.1 From b943d3c573c5189cbb5fc0bbaf6f2deeb2c547bd Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:16:07 +0200 Subject: [PATCH 03/13] conditional publish --- Jenkinsfile | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc0a019..3472ec6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -79,6 +79,31 @@ pipeline { //echo "hass: ${env.HASS_DEB}" } } + stage('publish') { + when { + branch "b" + } + steps { + script { + if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { + String cred_id = "gitea-user-${env.GITEA_USER}-full-token"; + withCredentials(credentialsId: cred_id, variable: 'GITEA_SECRET') { + sh "build/publish.sh" + } + //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" + //build( + // job: "/utils/apt", + // wait: true, + // propagate: true, + // parameters: [[ + // $class: 'StringParameterValue', + // name: 'filename', + // value: deb + // ]] + //) + } + } + } } post { always { @@ -89,24 +114,6 @@ pipeline { 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) - 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')]) { - sh "build/publish.sh" - } - //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" - //build( - // job: "/utils/apt", - // wait: true, - // propagate: true, - // parameters: [[ - // $class: 'StringParameterValue', - // name: 'filename', - // value: deb - // ]] - //) - } - } } cleanup { cleanWs(deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true) -- 2.40.1 From ba90ac4d4fbe471b3298175f58830552acd01d06 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:18:20 +0200 Subject: [PATCH 04/13] syntax --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3472ec6..d92251f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,7 +86,7 @@ pipeline { steps { script { if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { - String cred_id = "gitea-user-${env.GITEA_USER}-full-token"; + String cred_id = "gitea-user-${env.GITEA_USER}-full-token" withCredentials(credentialsId: cred_id, variable: 'GITEA_SECRET') { sh "build/publish.sh" } -- 2.40.1 From 4166076cbb5f301a247f419f6713135a3f629e49 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:20:09 +0200 Subject: [PATCH 05/13] syntax --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d92251f..59f0983 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,7 +87,7 @@ pipeline { script { if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { String cred_id = "gitea-user-${env.GITEA_USER}-full-token" - withCredentials(credentialsId: cred_id, variable: 'GITEA_SECRET') { + withCredentials([string(credentialsId: cred_id, variable: 'GITEA_SECRET')]) { sh "build/publish.sh" } //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" -- 2.40.1 From e80291bb16805ee411e7cb4b3d3759e7583642b1 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:22:53 +0200 Subject: [PATCH 06/13] syntax --- Jenkinsfile | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 59f0983..d23ab35 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,24 +84,7 @@ pipeline { branch "b" } steps { - script { - if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { - String cred_id = "gitea-user-${env.GITEA_USER}-full-token" - withCredentials([string(credentialsId: cred_id, variable: 'GITEA_SECRET')]) { - sh "build/publish.sh" - } - //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" - //build( - // job: "/utils/apt", - // wait: true, - // propagate: true, - // parameters: [[ - // $class: 'StringParameterValue', - // name: 'filename', - // value: deb - // ]] - //) - } + echo "no" } } } -- 2.40.1 From d9004c6232d67701f183e6afdc7e2dfb0225ed0c Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:23:35 +0200 Subject: [PATCH 07/13] syntax --- Jenkinsfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d23ab35..97dc1a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,7 +84,24 @@ pipeline { branch "b" } steps { - echo "no" + script { + if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { + String cred_id = "gitea-user-${env.GITEA_USER}-full-token" + withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { + sh "build/publish.sh" + } + //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" + //build( + // job: "/utils/apt", + // wait: true, + // propagate: true, + // parameters: [[ + // $class: 'StringParameterValue', + // name: 'filename', + // value: deb + // ]] + //) + } } } } -- 2.40.1 From 59e712222a42c2e8fab6ba4a79ee32c0db683fcc Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:48:21 +0200 Subject: [PATCH 08/13] syntax --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 97dc1a4..05f1dda 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,9 +86,8 @@ pipeline { steps { script { if (fileExists("build/publish.sh") && params.publish == true || params.force_publish == true) { - String cred_id = "gitea-user-${env.GITEA_USER}-full-token" - withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { - sh "build/publish.sh" + withCredentials([string(credentialsId: "gitea-user-${env.GITEA_USER}-full-token", variable: 'GITEA_SECRET')]) { + sh "build/publish.sh" } //sh "cp -v dist/${deb} ${env.JENKINS_HOME}/artifacts" //build( -- 2.40.1 From d6d85d3fb4857eb3c157d620cb630f627d88bd89 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 5 Apr 2024 09:49:52 +0200 Subject: [PATCH 09/13] syntax --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 05f1dda..13cd3c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -100,6 +100,7 @@ pipeline { // value: deb // ]] //) + } } } } -- 2.40.1 From 05963cad0bc0e3cddcce582f62ac6451d824c41e Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Sat, 6 Apr 2024 00:19:01 +0200 Subject: [PATCH 10/13] move comments around --- Dockerfile | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 999bfff..d0e09a9 100644 --- a/Dockerfile +++ b/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 && \ @@ -66,6 +61,12 @@ ENV VIRTUAL_ENV=${HASS_VENV_PATH} # 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 @@ -81,6 +82,13 @@ RUN set -x && \ /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" \ @@ -99,19 +107,9 @@ ENV MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:20000,m # For libc: #ENV LD_PRELOAD="/usr/lib/${arch}-linux-gnu/libjemalloc.so.2" # see: docker/bin/build-requirements.sh - -# 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. - -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/ +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 @@ -119,13 +117,15 @@ COPY --chown=hass:hass core/requirements_all.txt /usr/local/src/core/ # 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 && \ - /usr/local/bin/muslick.sh && \ - stat $LD_PRELOAD 1>/dev/null && \ - uv pip install -r requirements.txt && \ - uv pip install -r requirements_all.txt +# 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. RUN set -x && \ + uv pip install -r requirements.txt && \ + uv pip install -r requirements_all.txt && \ du -sh /usr/local/src/core/.venv/ && \ which python python3 pip uv -- 2.40.1 From 9d8b4833efa77823a9d84d186a10dcafd0371499 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Sat, 6 Apr 2024 00:19:07 +0200 Subject: [PATCH 11/13] frontend --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d1115dc..3e4b832 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ core/ +frontend/ dist/* target/* mount/ -- 2.40.1 From 8ffaacc115780dc7d4ce594481e128eabc047e67 Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 3 May 2024 23:53:16 +0200 Subject: [PATCH 12/13] frontend path --- rootfs/bin/frontend_path.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rootfs/bin/frontend_path.py b/rootfs/bin/frontend_path.py index 6c7b846..e766c68 100755 --- a/rootfs/bin/frontend_path.py +++ b/rootfs/bin/frontend_path.py @@ -3,6 +3,8 @@ import hass_frontend def frontend(): + # public/__init__.py + # in frimtens repi return hass_frontend.where() if __name__ == "__main__": -- 2.40.1 From 31ac372df5a3a30e7eb533399f74fec8bc47e9de Mon Sep 17 00:00:00 2001 From: Ben Kristinsson Date: Fri, 3 May 2024 23:57:21 +0200 Subject: [PATCH 13/13] disable jenkinsfile for now --- Jenkinsfile => Jenkinsfile.disabled | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jenkinsfile => Jenkinsfile.disabled (100%) diff --git a/Jenkinsfile b/Jenkinsfile.disabled similarity index 100% rename from Jenkinsfile rename to Jenkinsfile.disabled -- 2.40.1