This commit is contained in:
Alexandre
2025-07-20 16:46:47 +02:00
committed by GitHub
parent 3b2b7c549f
commit 0885037df0

View File

@@ -1,29 +1,30 @@
#============================# #============================#
# ALEXBELGIUM'S DOCKERFILE # # ALEXBELGIUM'S DOCKERFILE #
#============================# #============================#
# _.------. # ... ascii art omitted ...
# _.-` ('>.-`"""-. #=== Home Assistant Addon ENTE (server+web UI) ===#
# '.--'` _'` _ .--.)
# -' '-.-';` `
# ' - _.' ``'--.
# d '---` .-'""`
# /`
#=== Home Assistant Addon ENTE (server+web UI) ===#
######################################################## ########################################################
# 0 ▸ Build the enteweb static frontend (multistage) # # 0 ▸ Build the enteweb static frontend (multistage) #
######################################################## ########################################################
FROM node:22-alpine AS web-builder FROM node:22-alpine AS web-builder
# All web sources must live in ./ente-web relative to this Dockerfile # ---- buildtime selector; set `--build-arg ENTE_WEB_TAG=v3.6.0` if you
WORKDIR /src # want a specific release instead of main
COPY ente-web/ . ARG ENTE_WEB_TAG=main
# Use placeholders; they get patched at container startup # ---- tools we need to build (git, yarn)
RUN apk add --no-cache git && \
npm install -g yarn
# ---- pull the web source
WORKDIR /src
RUN git clone --depth 1 --branch "${ENTE_WEB_TAG}" https://github.com/ente-io/ente.git .
# ---- build web workspace (lives in ./web)
WORKDIR /src/web
ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER \ ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER \
NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER
# GitHub ARM runners sometimes timeout ⇒ raise network limit
RUN yarn config set network-timeout 900000 -g \ RUN yarn config set network-timeout 900000 -g \
&& yarn install --frozen-lockfile \ && yarn install --frozen-lockfile \
&& yarn build:photos \ && yarn build:photos \
@@ -41,20 +42,19 @@ FROM ghcr.io/ente-io/server:latest
################## ##################
# 2 ▸ Tune image # # 2 ▸ Tune image #
################## ##################
# ----- S6 flags -----
ENV S6_CMD_WAIT_FOR_SERVICES=1 \ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0 S6_SERVICES_GRACETIME=0
USER root USER root
# ----- LSIO helper ----- # --- LSIO helper (unchanged) ---
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, Postgres client & friends ----- # --- MinIO, psql client etc. (unchanged) ---
RUN set -eux; \ RUN set -eux; \
apk add --no-cache \ apk add --no-cache \
bash curl ca-certificates wget jq tini postgresql15-client; \ bash curl ca-certificates wget jq tini postgresql15-client; \
@@ -65,102 +65,69 @@ RUN apk add --no-cache \
lsb-release curl gnupg wget tini jq sudo \ lsb-release curl gnupg wget tini jq sudo \
postgresql postgresql-client postgresql postgresql-client
# ----- enteweb static bundle ----- # ---------- enteweb bundle ----------
RUN apk add --no-cache nginx RUN apk add --no-cache nginx
# Static files # static files built in the previous stage
COPY --from=web-builder /src/apps/photos/out /www/photos COPY --from=web-builder /src/web/apps/photos/out /www/photos
COPY --from=web-builder /src/apps/accounts/out /www/accounts COPY --from=web-builder /src/web/apps/accounts/out /www/accounts
COPY --from=web-builder /src/apps/auth/out /www/auth COPY --from=web-builder /src/web/apps/auth/out /www/auth
COPY --from=web-builder /src/apps/cast/out /www/cast COPY --from=web-builder /src/web/apps/cast/out /www/cast
# Nginx conf expected by /etc/cont-init.d/run.sh # nginx config & envpatch helper
RUN mkdir -p /etc/ente-web RUN mkdir -p /etc/ente-web
COPY <<'EOF' /etc/ente-web/nginx.conf COPY <<'EOF' /etc/ente-web/nginx.conf
worker_processes 1; worker_processes 1;
events { worker_connections 1024; } events { worker_connections 1024; }
http { http {
include mime.types; include mime.types; default_type application/octet-stream;
default_type application/octet-stream; sendfile on; keepalive_timeout 65;
sendfile on; server { listen 3000; root /www/photos; location / { try_files $uri $uri.html /index.html; } }
keepalive_timeout 65; server { listen 3001; root /www/accounts; location / { try_files $uri $uri.html /index.html; } }
server { listen 3002; root /www/photos; location / { try_files $uri $uri.html /index.html; } }
server { server { listen 3003; root /www/auth; location / { try_files $uri $uri.html /index.html; } }
listen 3000; server { listen 3004; root /www/cast; location / { try_files $uri $uri.html /index.html; } }
root /www/photos;
location / { try_files $uri $uri.html /index.html; }
}
server {
listen 3001;
root /www/accounts;
location / { try_files $uri $uri.html /index.html; }
}
server {
listen 3002;
root /www/photos;
location / { try_files $uri $uri.html /index.html; }
}
server {
listen 3003;
root /www/auth;
location / { try_files $uri $uri.html /index.html; }
}
server {
listen 3004;
root /www/cast;
location / { try_files $uri $uri.html /index.html; }
}
} }
EOF EOF
# Runtime placeholder replacement
COPY <<'EOF' /usr/local/bin/ente-web-prepare COPY <<'EOF' /usr/local/bin/ente-web-prepare
#!/usr/bin/env ash #!/usr/bin/env ash
set -eu set -eu
: "${ENTE_API_ORIGIN:=http://localhost:8080}" : "${ENTE_API_ORIGIN:=http://localhost:8080}"
: "${ENTE_ALBUMS_ORIGIN:=${ENTE_API_ORIGIN}}" : "${ENTE_ALBUMS_ORIGIN:=${ENTE_API_ORIGIN}}"
echo "[ente-web-prepare] Substituting origins…"
echo "[ente-web-prepare] Patching bundles:"
echo " ENTE_API_ORIGIN = $ENTE_API_ORIGIN"
echo " ENTE_ALBUMS_ORIGIN = $ENTE_ALBUMS_ORIGIN"
find /www -name '*.js' | xargs sed -i "s#ENTE_API_ORIGIN_PLACEHOLDER#${ENTE_API_ORIGIN}#g" find /www -name '*.js' | xargs sed -i "s#ENTE_API_ORIGIN_PLACEHOLDER#${ENTE_API_ORIGIN}#g"
find /www/photos -name '*.js' | xargs sed -i "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#${ENTE_ALBUMS_ORIGIN}#g" find /www/photos -name '*.js'| xargs sed -i "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#${ENTE_ALBUMS_ORIGIN}#g"
EOF EOF
RUN chmod +x /usr/local/bin/ente-web-prepare RUN chmod +x /usr/local/bin/ente-web-prepare
################## ##################
# 3 ▸ Add-ons, etc. # # 3 ▸ Install addon helpers (unchanged) #
################## ##################
COPY rootfs/ / COPY rootfs/ /
# Optional modules
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
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 # # 4 ▸ Entrypoint (unchanged) #
################ ################
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"] ENTRYPOINT ["/usr/bin/env"]
CMD ["/ha_entrypoint.sh"] CMD ["/ha_entrypoint.sh"]
############ ############
# 5 ▸ Labels # # 5 ▸ Labels (unchanged) #
############ ############
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 \
@@ -182,8 +149,4 @@ LABEL \
################# #################
# 6 ▸ Finish line # # 6 ▸ Finish line #
################# #################
# S6 will detect scripts in /etc/services.d (copied via rootfs)
# and launch → minio → museum API → nginx (enteweb)
# Expose the SPA ports so HA can map them
EXPOSE 3000 3001 3002 3003 3004 EXPOSE 3000 3001 3002 3003 3004