mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-31 04:44:05 +02:00
Refactor
This commit is contained in:
277
ente/Dockerfile
277
ente/Dockerfile
@@ -8,214 +8,133 @@
|
|||||||
# ' - _.' ``'--.
|
# ' - _.' ``'--.
|
||||||
# d '---` .-'""`
|
# d '---` .-'""`
|
||||||
# /`
|
# /`
|
||||||
|
#=== Home Assistant Add‑on – ENTE ===#
|
||||||
############################
|
|
||||||
# Stage 0: pull web assets #
|
|
||||||
############################
|
|
||||||
FROM ghcr.io/ente-io/web:latest AS enteweb
|
|
||||||
# This image already contains the built static outputs for photos/accounts/auth/cast
|
|
||||||
# under /out plus a default nginx conf. We’ll copy those into the final image.
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# 1 Base Image #
|
# 1 Build Image #
|
||||||
#################
|
#################
|
||||||
ARG BUILD_VERSION
|
ARG BUILD_VERSION
|
||||||
|
|
||||||
|
# Stage 1: Build the web part
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
WORKDIR /build
|
||||||
|
COPY . .
|
||||||
|
ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER
|
||||||
|
ENV NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER
|
||||||
|
# `yarn install` is flaky on the GitHub arm64 runners otherwise.
|
||||||
|
RUN yarn config set network-timeout 900000 -g
|
||||||
|
RUN yarn install
|
||||||
|
RUN yarn build:photos
|
||||||
|
RUN yarn build:accounts
|
||||||
|
RUN yarn build:auth
|
||||||
|
RUN yarn build:cast
|
||||||
|
|
||||||
|
# Stage 2: Final image with both server and web parts
|
||||||
FROM ghcr.io/ente-io/server:latest
|
FROM ghcr.io/ente-io/server:latest
|
||||||
|
|
||||||
#########################
|
##################
|
||||||
# 2 S6 / base settings #
|
# 2 Modify Image #
|
||||||
#########################
|
##################
|
||||||
|
# S6 settings
|
||||||
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 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 server/client + nginx etc #
|
|
||||||
########################################################
|
|
||||||
RUN set -eux \
|
|
||||||
&& apk update \
|
|
||||||
&& apk add --no-cache \
|
|
||||||
bash curl ca-certificates wget jq sudo tzdata tini \
|
|
||||||
postgresql postgresql-client \
|
|
||||||
nginx \
|
|
||||||
&& ln -sf /usr/bin/bash /bin/bash
|
|
||||||
|
|
||||||
###################################
|
|
||||||
# 5 MinIO server + CLI (per‑arch) #
|
|
||||||
###################################
|
|
||||||
ARG TARGETARCH
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
arch="${TARGETARCH:-$(uname -m)}"; \
|
apk add --no-cache \
|
||||||
case "$arch" in \
|
bash curl ca-certificates wget jq tini postgresql15-client; \
|
||||||
amd64|x86_64) minio_arch="amd64" ;; \
|
curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio; \
|
||||||
arm64|aarch64) minio_arch="arm64" ;; \
|
curl -fsSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc; \
|
||||||
*) 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 \
|
||||||
|
lsb-release curl gnupg wget tini jq sudo \
|
||||||
|
postgresql postgresql-client nginx
|
||||||
|
|
||||||
#####################################################
|
# Copy the built web part from the builder stage
|
||||||
# 6 Copy Ente web static assets from enteweb stage #
|
COPY --from=builder /build/apps/photos/out /out/photos
|
||||||
#####################################################
|
COPY --from=builder /build/apps/accounts/out /out/accounts
|
||||||
# Static output (architecture‑independent)
|
COPY --from=builder /build/apps/auth/out /out/auth
|
||||||
COPY --from=enteweb /out/ /opt/ente-web/out/
|
COPY --from=builder /build/apps/cast/out /out/cast
|
||||||
# We’ll supply our own nginx conf tuned for HA add‑on ports.
|
|
||||||
COPY <<'EOF' /etc/ente-web/nginx.conf
|
|
||||||
# Minimal nginx master config that includes our vhosts.
|
|
||||||
worker_processes auto;
|
|
||||||
pid /run/nginx.pid;
|
|
||||||
events { worker_connections 1024; }
|
|
||||||
|
|
||||||
http {
|
# Configure Nginx
|
||||||
include /etc/nginx/mime.types;
|
COPY <<EOF /etc/nginx/conf.d/default.conf
|
||||||
default_type application/octet-stream;
|
server {
|
||||||
sendfile on;
|
listen 3000; root /out/photos;
|
||||||
keepalive_timeout 65;
|
location / { try_files \$uri \$uri.html /index.html; }
|
||||||
|
}
|
||||||
# gzip etc. optional
|
server {
|
||||||
server_tokens off;
|
listen 3001; root /out/accounts;
|
||||||
|
location / { try_files \$uri \$uri.html /index.html; }
|
||||||
# Photos (main UI) - port 3000
|
}
|
||||||
server {
|
server {
|
||||||
listen 3000;
|
listen 3002; root /out/photos;
|
||||||
root /opt/ente-web/out/photos;
|
location / { try_files \$uri \$uri.html /index.html; }
|
||||||
index index.html;
|
}
|
||||||
location / {
|
server {
|
||||||
try_files $uri $uri/ /index.html;
|
listen 3003; root /out/auth;
|
||||||
}
|
location / { try_files \$uri \$uri.html /index.html; }
|
||||||
}
|
}
|
||||||
|
server {
|
||||||
# Accounts - port 3001
|
listen 3004; root /out/cast;
|
||||||
server {
|
location / { try_files \$uri \$uri.html /index.html; }
|
||||||
listen 3001;
|
|
||||||
root /opt/ente-web/out/accounts;
|
|
||||||
index index.html;
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Public albums - port 3002
|
|
||||||
server {
|
|
||||||
listen 3002;
|
|
||||||
root /opt/ente-web/out/photos;
|
|
||||||
index index.html;
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Auth - port 3003
|
|
||||||
server {
|
|
||||||
listen 3003;
|
|
||||||
root /opt/ente-web/out/auth;
|
|
||||||
index index.html;
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Cast - port 3004
|
|
||||||
server {
|
|
||||||
listen 3004;
|
|
||||||
root /opt/ente-web/out/cast;
|
|
||||||
index index.html;
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Runtime env replacement script (mirrors official ente web Dockerfile behaviour)
|
# Environment variables for the web part
|
||||||
COPY <<'EOF' /usr/local/bin/ente-web-prepare
|
ENV ENTE_API_ORIGIN=http://localhost:8080
|
||||||
#!/usr/bin/env sh
|
ENV ENTE_ALBUMS_ORIGIN=https://localhost:3002
|
||||||
set -eu
|
|
||||||
|
|
||||||
API_ORIGIN="${ENTE_API_ORIGIN:-http://localhost:8080}"
|
# Script to replace environment variables in the JavaScript files
|
||||||
ALBUMS_ORIGIN="${ENTE_ALBUMS_ORIGIN:-http://localhost:3002}"
|
RUN mkdir -p /docker-entrypoint.d
|
||||||
|
COPY <<EOF /docker-entrypoint.d/90-replace-ente-env.sh
|
||||||
# Replace placeholders in built JS bundles
|
#!/bin/sh
|
||||||
# These placeholders exist in official Ente web builds.
|
find /out -name '*.js' |
|
||||||
find /opt/ente-web/out -type f -name '*.js' -print0 \
|
xargs sed -i'' "s#ENTE_API_ORIGIN_PLACEHOLDER#\$ENTE_API_ORIGIN#g"
|
||||||
| xargs -0 sed -i "s#ENTE_API_ORIGIN_PLACEHOLDER#${API_ORIGIN}#g"
|
find /out/photos -name '*.js' |
|
||||||
|
xargs sed -i'' "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#\$ENTE_ALBUMS_ORIGIN#g"
|
||||||
# Albums origin applies only to photos app
|
|
||||||
if [ -d /opt/ente-web/out/photos ]; then
|
|
||||||
find /opt/ente-web/out/photos -type f -name '*.js' -print0 \
|
|
||||||
| xargs -0 sed -i "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#${ALBUMS_ORIGIN}#g"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
EOF
|
EOF
|
||||||
RUN chmod +x /usr/local/bin/ente-web-prepare
|
RUN chmod +x /docker-entrypoint.d/90-replace-ente-env.sh
|
||||||
|
|
||||||
USER root
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# 3 Install apps #
|
# 3 Install apps #
|
||||||
##################
|
##################
|
||||||
# Copy local files
|
|
||||||
COPY rootfs/ /
|
COPY rootfs/ /
|
||||||
|
# bind‑compat for some addons
|
||||||
# Uses /bin for compatibility purposes
|
#RUN ln -sf /usr/bin/bash /bin/bash || true && \
|
||||||
# hadolint ignore=DL4005
|
# ln -sf /usr/bin/sh /bin/sh || true
|
||||||
#RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \
|
# Optional modules (same pattern as ente)
|
||||||
# if [ ! -f /bin/bash ] && [ -f /usr/bin/bash ]; then ln -s /usr/bin/bash /bin/bash; fi
|
ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.sh 00-smb_mounts.sh"
|
||||||
|
|
||||||
# Modules
|
|
||||||
ARG MODULES="00-banner.sh 01-custom_script.sh 00-local_mounts.sh 00-smb_mounts.sh"
|
|
||||||
|
|
||||||
# Automatic modules download
|
|
||||||
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
|
||||||
# Manual apps
|
ENV PACKAGES="sudo jq yamllint"
|
||||||
ENV PACKAGES="nginx"
|
|
||||||
|
|
||||||
# Automatic apps & bashio
|
|
||||||
|
|
||||||
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automatic_packages.sh" "/ha_automatic_packages.sh"
|
|
||||||
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
|
||||||
|
|
||||||
################
|
################
|
||||||
# 8 Entrypoint #
|
# 4 Entrypoint #
|
||||||
################
|
################
|
||||||
|
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
|
||||||
# Add entrypoint
|
|
||||||
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"
|
||||||
|
|
||||||
# Entrypoint modifications
|
|
||||||
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 && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh
|
RUN chmod 777 /ha_entrypoint.sh /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" ]
|
||||||
|
# ---------- 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
|
|
||||||
|
|
||||||
############
|
############
|
||||||
# 11 Labels #
|
# 5 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 \
|
||||||
@@ -223,18 +142,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}
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# 12 Finish line#
|
# 6 Finish line #
|
||||||
#################
|
#################
|
||||||
# Startup orchestrated by /etc/cont-init.d/99-run.sh (museum, Postgres, MinIO, nginx web).
|
# S6 will pick up run scripts from /etc/services.d supplied in rootfs
|
||||||
|
# and launch: › minio › museum API › (optional) web‑UI
|
||||||
|
|||||||
Reference in New Issue
Block a user