try refactor

This commit is contained in:
Alexandre
2025-07-16 08:40:07 +02:00
committed by GitHub
parent 37656c7e8d
commit 178e14962d
2 changed files with 76 additions and 59 deletions

View File

@@ -11,89 +11,107 @@
#=== Home Assistant Addon ENTE ===# #=== Home Assistant Addon ENTE ===#
################# #################
# 1 Build Image # # 1 Base Image #
################# #################
ARG BUILD_VERSION ARG BUILD_VERSION
FROM ghcr.io/ente-io/server:latest FROM ghcr.io/ente-io/server:latest
################## #########################
# 2 Modify Image # # 2 S6 / base settings #
################## #########################
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
# S6 settings S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
ENV S6_CMD_WAIT_FOR_SERVICES=1 \ S6_SERVICES_GRACETIME=0
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
USER root USER root
# LSIO helpers (same repo you already use) #############################################
# 3 LSIO helper patch (same pattern as you) #
#############################################
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh"
ARG CONFIGLOCATION="/config" ARG CONFIGLOCATION="/config"
RUN chmod 744 /ha_lsio.sh && \ RUN chmod 744 /ha_lsio.sh \
if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && \ && if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi \
rm /ha_lsio.sh && rm /ha_lsio.sh
# ---------- MinIO & tools (needed by Ente) ---------- ########################################################
# server binary + client (`mc`) # 4 Core packages + Postgres 17 server & client (apk) #
########################################################
# NOTE: Ente base image is Alpine; use apk. We install bash for bashio scripts.
# Try to pull PG17 from edge; if unavailable fall back to distro default (may be lower major).
RUN set -eux; \ RUN set -eux; \
apk add --no-cache \ apk update; \
bash curl ca-certificates wget jq tini postgresql15-client; \ apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \
curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio; \ bash curl ca-certificates wget jq sudo tzdata \
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc; \ postgresql17 postgresql17-client || \
(echo "edge PG17 not available, falling back to distro postgresql"; \
apk add --no-cache postgresql postgresql-client bash curl ca-certificates wget jq sudo tzdata); \
# create /bin/bash symlink for scripts that expect it
ln -sf /usr/bin/bash /bin/bash
###################################
# 5 MinIO server + CLI (perarch) #
###################################
# Detect arch at build time using Alpine uname.
ARG TARGETARCH
RUN set -eux; \
arch="${TARGETARCH:-$(uname -m)}"; \
case "$arch" in \
amd64|x86_64) minio_arch="amd64" ;; \
arm64|aarch64) minio_arch="arm64" ;; \
*) minio_arch="amd64" ;; \
esac; \
curl -fsSL "https://dl.min.io/server/minio/release/linux-${minio_arch}/minio" -o /usr/local/bin/minio; \
curl -fsSL "https://dl.min.io/client/mc/release/linux-${minio_arch}/mc" -o /usr/local/bin/mc; \
chmod +x /usr/local/bin/minio /usr/local/bin/mc chmod +x /usr/local/bin/minio /usr/local/bin/mc
RUN apk update && \ #####################################################
apk add --no-cache \ # 6 Ensure predictable paths for museum & enteweb #
lsb-release curl gnupg wget tini jq sudo \ #####################################################
postgresql postgresql-client RUN set -eux; \
MUSEUM_PATH="$(command -v museum || true)"; \
# Put museum / web on a predictable path for your run-scripts if [ -n "$MUSEUM_PATH" ]; then ln -sf "$MUSEUM_PATH" /usr/bin/museum; fi; \
RUN ln -sf $(command -v museum) /usr/bin/museum && \ WEB_PATH="$(command -v ente-web || true)"; \
ln -sf $(command -v ente-web) /usr/bin/ente-web if [ -n "$WEB_PATH" ]; then ln -sf "$WEB_PATH" /usr/bin/ente-web; fi
################## ##################
# 3 Install apps # # 7 Install apps #
################## ##################
# Optional modules (same pattern as your other addons)
COPY rootfs/ /
# bindcompat for some addons
#RUN ln -sf /usr/bin/bash /bin/bash || true && \
# ln -sf /usr/bin/sh /bin/sh || true
# Optional modules (same pattern as ente)
ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.sh 00-smb_mounts.sh" ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.sh 00-smb_mounts.sh"
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" "/ha_automodules.sh" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" "/ha_automodules.sh"
RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh
# Optional extra packages # Optional extra packages via your helper
ENV PACKAGES="sudo jq yamllint" ENV PACKAGES="sudo jq yamllint"
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh"
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
################ ################
# 4 Entrypoint # # 8 Entrypoint #
################ ################
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh"
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh" ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh"
RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && \ RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh \
/ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh
ENTRYPOINT [ "/usr/bin/env" ] ############################
CMD [ "/ha_entrypoint.sh" ] # 9 Copy addon rootfs tree #
############################
# (bashioaware continit.d + services.d scripts)
COPY rootfs/ /
# ---------- Healthcheck ---------- ##########################################
#ENV HEALTH_PORT="8080" \ # 10 Healthcheck (museum exposes /ping) #
# HEALTH_URL="/ping" ##########################################
#HEALTHCHECK --interval=10s --retries=5 --timeout=20s CMD \ ENV HEALTH_PORT="8080" \
# curl -A "HealthCheck: Docker/1.0" -fs "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" || exit 1 HEALTH_URL="/ping"
HEALTHCHECK --interval=10s --retries=5 --timeout=20s CMD \
curl -A "HealthCheck: Docker/1.0" -fs "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" || exit 1
############ ############
# 5 Labels # # 11 Labels #
############ ############
ARG BUILD_ARCH BUILD_DATE BUILD_NAME BUILD_DESCRIPTION BUILD_REF BUILD_REPOSITORY ARG BUILD_ARCH BUILD_DATE BUILD_NAME BUILD_DESCRIPTION BUILD_REF BUILD_REPOSITORY
LABEL \ LABEL \
@@ -101,19 +119,18 @@ LABEL \
io.hass.description="${BUILD_DESCRIPTION}" \ io.hass.description="${BUILD_DESCRIPTION}" \
io.hass.arch="${BUILD_ARCH}" \ io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \ io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \ io.hass.version="${BUILD_VERSION}" \
maintainer="alexbelgium (https://github.com/alexbelgium)" \ maintainer="alexbelgium (https://github.com/alexbelgium)" \
org.opencontainers.image.title="${BUILD_NAME}" \ org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.url="https://github.com/alexbelgium" \ org.opencontainers.image.url="https://github.com/alexbelgium" \
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ 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.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
org.opencontainers.image.created=${BUILD_DATE} \ org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision=${BUILD_REF} \ org.opencontainers.image.revision="${BUILD_REF}" \
org.opencontainers.image.version=${BUILD_VERSION} org.opencontainers.image.version="${BUILD_VERSION}"
################# #################
# 6 Finish line # # 12 Finish line#
################# #################
# S6 will pick up run scripts from /etc/services.d supplied in rootfs # S6 supervises internal services; no CMD override.
# and launch: minio museum API (optional) webUI

View File

@@ -77,7 +77,7 @@
"startup": "services", "startup": "services",
"udev": true, "udev": true,
"url": "https://github.com/alexbelgium/hassio-addons", "url": "https://github.com/alexbelgium/hassio-addons",
"version": "1.0.0test3", "version": "1.0.0test4",
"video": true, "video": true,
"webui": "http://[HOST]:[PORT:3000]" "webui": "http://[HOST]:[PORT:3000]"
} }