Files
hassio-addons/zoraxy/Dockerfile
Alexandre 1c888badc7 fix(zoraxy): restore apk removed by the upstream image build (#3024)
* fix(zoraxy): restore apk removed by the upstream image build

Upstream's image build has ended with "rm -rf /sbin/apk" since v3.3.4. The
binary is deleted but /etc/apk (repositories, keys, world) and /lib/apk/db
survive, so package management is recoverable. The image also ships neither
bash nor curl, so ha_automodules.sh failed with "apt-get: not found / apk:
not found" (exit 127) and both architectures failed to build.

Restore the statically-linked apk binary from an Alpine build stage before the
shared module and package scripts run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(zoraxy): keep BUILD_FROM a global build arg

Declaring the tools stage above the ARG lines scoped BUILD_FROM to that stage,
so the final FROM resolved to an empty base name. Move both global ARGs above
the first FROM.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(skill): record the global-ARG and vanishing-package-manager traps

Both cost a CI cycle on PR #3024: a tools stage inserted above ARG BUILD_FROM
demoted it to stage scope, and the upstream image had started deleting
/sbin/apk between releases.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-29 07:12:21 +02:00

137 lines
4.2 KiB
Docker

#============================#
# ALEXBELGIUM'S DOCKERFILE #
#============================#
# _.------.
# _.-` ('>.-`"""-.
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# '---` .-'""`
# /`
#=== Home Assistant Addon ===#
# Declared before the first FROM so they stay global build args, usable by the
# FROM of the final stage below.
ARG BUILD_FROM
ARG BUILD_VERSION
############################
# 0 Tools stage (apk OK) #
############################
# Upstream's image build ends with "rm -rf /sbin/apk" (added in v3.3.4), which
# deletes the package manager binary but leaves /etc/apk (repositories, keys,
# world) and /lib/apk/db intact. The shared build scripts below need a package
# manager to install bash, curl and jq, none of which the image ships, so
# restore apk from its statically-linked build. Keep this Alpine tag in sync
# with the upstream base image (currently alpine-minirootfs-3.24.1).
FROM alpine:3.24 AS ha_apk
RUN apk add --no-cache apk-tools-static
#################
# 1 Build Image #
#################
FROM ${BUILD_FROM}
##################
# 2 Modify Image #
##################
# Set S6 wait time
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
USER root
##################
# 3 Install apps #
##################
# Add rootfs
COPY rootfs/ /
RUN find . -type f \( -name "*.sh" -o -name "run" -o -name "finish" \) -print -exec chmod +x {} \;
# Uses /bin for compatibility purposes
# hadolint ignore=DL4005
RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \
if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi
# Persist Zoraxy data in /config (addon_config) instead of the ephemeral
# upstream working directory, so the configuration survives add-on updates.
RUN sed -i 's#/opt/zoraxy/config#/config#g' /opt/zoraxy/entrypoint.py
# Restore the package manager deleted by the upstream image build (see stage 0)
COPY --from=ha_apk /sbin/apk.static /sbin/apk
# Modules
ARG MODULES="00-banner.sh"
# Automatic modules download
COPY ha_automodules.sh /ha_automodules.sh
RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh
# Manual apps
ENV PACKAGES="jq"
# Automatic apps & bashio
COPY ha_autoapps.sh /ha_autoapps.sh
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
################
# 4 Entrypoint #
################
# Add entrypoint
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
COPY ha_entrypoint.sh /ha_entrypoint.sh
RUN chmod 777 /ha_entrypoint.sh
WORKDIR /
ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/ha_entrypoint.sh" ]
############
# 5 Labels #
############
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
ENV BUILD_VERSION="${BUILD_VERSION}"
LABEL \
io.hass.name="${BUILD_NAME}" \
io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="Home Assistant Add-ons" \
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}
#################
# 6 Healthcheck #
#################
ENV HEALTH_PORT="8000" \
HEALTH_URL=""
HEALTHCHECK \
--interval=5s \
--retries=5 \
--start-period=30s \
--timeout=25s \
CMD curl -A "HealthCheck: Docker/1.0" -s -f "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" &>/dev/null || curl -k --fail "https://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" &>/dev/null || exit 1