Skip to content

Commit

Permalink
Base Image: S6 overlay & jemalloc update (home-assistant#72425)
Browse files Browse the repository at this point in the history
* Update base image with new s6-Overlay & jemalloc

* add build version

* Update finish
  • Loading branch information
pvizeli authored May 24, 2022
1 parent 23bd64b commit 6368df5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 45 deletions.
10 changes: 5 additions & 5 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
image: homeassistant/{arch}-homeassistant
shadow_repository: ghcr.io/home-assistant
build_from:
aarch64: ghcr.io/home-assistant/aarch64-homeassistant-base:2022.02.0
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2022.02.0
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2022.02.0
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2022.02.0
i386: ghcr.io/home-assistant/i386-homeassistant-base:2022.02.0
aarch64: ghcr.io/home-assistant/aarch64-homeassistant-base:2022.05.0
armhf: ghcr.io/home-assistant/armhf-homeassistant-base:2022.05.0
armv7: ghcr.io/home-assistant/armv7-homeassistant-base:2022.05.0
amd64: ghcr.io/home-assistant/amd64-homeassistant-base:2022.05.0
i386: ghcr.io/home-assistant/i386-homeassistant-base:2022.05.0
codenotary:
signer: notary@home-assistant.io
base_image: notary@home-assistant.io
Expand Down
42 changes: 24 additions & 18 deletions rootfs/etc/services.d/home-assistant/finish
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
#!/usr/bin/execlineb -S1
#!/usr/bin/env bashio
# ==============================================================================
# Take down the S6 supervision tree when Home Assistant fails
# ==============================================================================
define HA_RESTART_EXIT_CODE 100
define SIGNAL_EXIT_CODE 256
define SIGTERM 15
declare RESTART_EXIT_CODE 100
declare SIGNAL_EXIT_CODE 256
declare SIGTERM 15
declare APP_EXIT_CODE=${1}
declare SYS_EXIT_CODE=${2+x}
declare NEW_EXIT_CODE=

foreground { s6-echo "[finish] process exit code ${1}" }
bashio::log.info "Home Assistant Core finish process exit code ${1}"

if { s6-test ${1} -ne ${HA_RESTART_EXIT_CODE} }
ifelse { s6-test ${1} -eq ${SIGNAL_EXIT_CODE} } {
# Process terminated by a signal
define signal ${2}
foreground { s6-echo "[finish] process received signal ${signal}" }
backtick -n new_exit_code { s6-expr 128 + ${signal} }
importas -ui new_exit_code new_exit_code
foreground { redirfd -w 1 /var/run/s6/env-stage3/S6_STAGE2_EXITED s6-echo -n -- ${new_exit_code} }
if { s6-test ${signal} -ne ${SIGTERM} }
s6-svscanctl -t /var/run/s6/services
}
if [[ ${APP_EXIT_CODE} -eq ${RESTART_EXIT_CODE} ]]; then
exit 0
elif [[ ${APP_EXIT_CODE} -eq ${SIGNAL_EXIT_CODE} ]]; then
bashio::log.info "Home Assistant Core finish process received signal ${APP_EXIT_CODE}"

foreground { redirfd -w 1 /var/run/s6/env-stage3/S6_STAGE2_EXITED s6-echo -n -- ${1} }
s6-svscanctl -t /var/run/s6/services
NEW_EXIT_CODE=$((128 + SYS_EXIT_CODE))
echo ${NEW_EXIT_CODE} > /run/s6-linux-init-container-results/exitcode

if [[ ${NEW_EXIT_CODE} -eq ${SIGTERM} ]]; then
/run/s6/basedir/bin/halt
fi
else
bashio::log.info "Home Assistant Core service shutdown"

echo ${APP_EXIT_CODE} > /run/s6-linux-init-container-results/exitcode
/run/s6/basedir/bin/halt
fi
Empty file modified rootfs/etc/services.d/home-assistant/run
100644 → 100755
Empty file.
70 changes: 48 additions & 22 deletions rootfs/init
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
#!/bin/execlineb -S0

##
## load default PATH (the same that Docker includes if not provided) if it doesn't exist,
## then go ahead with stage1.
## this was motivated due to this issue:
## - https://github.com/just-containers/s6-overlay/issues/108
##

/bin/importas -D /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH PATH
export PATH ${PATH}

##
## Skip further init if the user has a given CMD.
## This is to prevent Home Assistant from starting twice if the user
## decided to override/start via the CMD.
##

ifelse { s6-test $# -ne 0 }
{
$@
#!/usr/bin/env bashio

# This is the first program launched at container start.
# We don't know where our binaries are and we cannot guarantee
# that the default PATH can access them.
# So this script needs to be entirely self-contained until it has
# at least /command, /usr/bin and /bin in its PATH.

addpath () {
x="$1"
IFS=:
set -- $PATH
IFS=
while test "$#" -gt 0 ; do
if test "$1" = "$x" ; then
return
fi
shift
done
PATH="${x}:$PATH"
}
/etc/s6/init/init-stage1 $@

if test -z "$PATH" ; then
PATH=/bin
fi

addpath /bin
addpath /usr/bin
addpath /command
export PATH

# Now we're good: s6-overlay-suexec is accessible via PATH, as are
# all our binaries.

# Skip further init if the user has a given CMD.
# This is to prevent Home Assistant from starting twice if the user
# decided to override/start via the CMD.
if test $# -ne 0 ; then
exec "$@"
fi

# Run preinit as root, then run stage0 as the container's user (can be
# root, can be a normal user).

exec s6-overlay-suexec \
' /package/admin/s6-overlay-@VERSION@/libexec/preinit' \
'' \
/package/admin/s6-overlay-@VERSION@/libexec/stage0 \
"$@"

0 comments on commit 6368df5

Please sign in to comment.