diff --git a/grampsweb/CHANGELOG.md b/grampsweb/CHANGELOG.md new file mode 100644 index 000000000..8d414fa40 --- /dev/null +++ b/grampsweb/CHANGELOG.md @@ -0,0 +1 @@ +- First version diff --git a/grampsweb/Dockerfile b/grampsweb/Dockerfile new file mode 100644 index 000000000..09d6495ec --- /dev/null +++ b/grampsweb/Dockerfile @@ -0,0 +1,123 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_VERSION +ARG BUILD_FROM +FROM ${BUILD_FROM} +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +################## +# 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 + + - gramps_users:/app/users # persist user database + - gramps_index:/app/indexdir # persist search index + - gramps_thumb_cache:/app/thumbnail_cache # persist thumbnails + - gramps_cache:/app/cache # persist export and report caches + - gramps_secret:/app/secret # persist flask secret + - gramps_db:/root/.gramps/grampsdb # persist Gramps database + - gramps_media:/app/media # persist media files + - gramps_tmp:/tmp + + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# 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 + +# Modules +ARG MODULES="" + +# Automatic modules download +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 + +# Manual apps +ENV PACKAGES="sudo redis nginx" + +# Automatic apps & bashio +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 + +################ +# 4 Entrypoint # +################ + +# 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" + +# Entrypoint modifications +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 + +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 +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="8080" \ + HEALTH_URL="" +HEALTHCHECK \ + --interval=5s \ + --retries=5 \ + --start-period=30s \ + --timeout=25s \ + CMD curl --fail "http://127.0.0.1:${HEALTH_PORT}${HEALTH_URL}" &>/dev/null || exit 1 diff --git a/grampsweb/README.md b/grampsweb/README.md new file mode 100644 index 000000000..f3f7ecd07 --- /dev/null +++ b/grampsweb/README.md @@ -0,0 +1 @@ +# Home assistant add-on: grampsweb diff --git a/grampsweb/apparmor.txt b/grampsweb/apparmor.txt new file mode 100644 index 000000000..ddb432d34 --- /dev/null +++ b/grampsweb/apparmor.txt @@ -0,0 +1,66 @@ +#include + +profile grampsweb_addon flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + signal, + mount, + umount, + remount, + network udp, + network tcp, + network dgram, + network stream, + network inet, + network inet6, + network netlink raw, + network unix dgram, + + capability setgid, + capability setuid, + capability sys_admin, + capability dac_read_search, + # capability dac_override, + # capability sys_rawio, + +# S6-Overlay + /init ix, + /run/{s6,s6-rc*,service}/** ix, + /package/** ix, + /command/** ix, + /run/{,**} rwk, + /dev/tty rw, + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + # Files required + /dev/fuse mrwkl, + /dev/sda1 mrwkl, + /dev/sdb1 mrwkl, + /dev/nvme0 mrwkl, + /dev/nvme1 mrwkl, + /dev/mmcblk0p1 mrwkl, + /dev/* mrwkl, + /tmp/** mrkwl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/grampsweb/build.yaml b/grampsweb/build.yaml new file mode 100644 index 000000000..66d0f6022 --- /dev/null +++ b/grampsweb/build.yaml @@ -0,0 +1,6 @@ +--- +build_from: + aarch64: ghcr.io/gramps-project/grampsweb:latest + amd64: ghcr.io/gramps-project/grampsweb:latest +codenotary: + signer: alexandrep.github@gmail.com diff --git a/grampsweb/config.yaml b/grampsweb/config.yaml new file mode 100644 index 000000000..8beb4e01c --- /dev/null +++ b/grampsweb/config.yaml @@ -0,0 +1,106 @@ +arch: +- aarch64 +- amd64 +codenotary: alexandrep.github@gmail.com +description: Open Source Online Genealogy System +devices: +- "/dev/dri" +- "/dev/dri/card0" +- "/dev/dri/card1" +- "/dev/dri/renderD128" +- "/dev/vchiq" +- "/dev/video10" +- "/dev/video11" +- "/dev/video12" +- "/dev/video13" +- "/dev/video14" +- "/dev/video15" +- "/dev/video16" +- "/dev/ttyUSB0" +- "/dev/sda" +- "/dev/sdb" +- "/dev/sdc" +- "/dev/sdd" +- "/dev/sde" +- "/dev/sdf" +- "/dev/sdg" +- "/dev/nvme" +- "/dev/nvme0n1p1" +- "/dev/nvme0n1p2" +- "/dev/nvme0n1p3" +- "/dev/nvme1n1p1" +- "/dev/nvme1n1p2" +- "/dev/nvme1n1p3" +- "/dev/nvme2n1p1" +- "/dev/nvme2n1p2" +- "/dev/nvme3n1p3" +- "/dev/mmcblk" +- "/dev/fuse" +- "/dev/sda1" +- "/dev/sdb1" +- "/dev/sdc1" +- "/dev/sdd1" +- "/dev/sde1" +- "/dev/sdf1" +- "/dev/sdg1" +- "/dev/sda2" +- "/dev/sdb2" +- "/dev/sdc2" +- "/dev/sdd2" +- "/dev/sde2" +- "/dev/sdf2" +- "/dev/sdg2" +- "/dev/sda3" +- "/dev/sdb3" +- "/dev/sda4" +- "/dev/sdb4" +- "/dev/sda5" +- "/dev/sda6" +- "/dev/sda7" +- "/dev/sda8" +- "/dev/nvme0" +- "/dev/nvme1" +- "/dev/nvme2" +environment: { + "GRAMPSWEB_TREE": "Gramps Web", + "GRAMPSWEB_CELERY_CONFIG__broker_url": "redis://localhost:6379/0", + "GRAMPSWEB_CELERY_CONFIG__result_backend": "redis://localhost:6379/0", + "GRAMPSWEB_RATELIMIT_STORAGE_URI": "redis://localhost:6379/1" +} +image: ghcr.io/alexbelgium/grampsweb-{arch} +init: false +options: { + "database": "sqlite" +} +map: + - type: addon_config + read_only: false +name: Monica +ports: + 80/tcp: 5000 +ports_description: + 80/tcp: webui +schema: { + "database": "list(sqlite|MariaDB_addon|Mysql_external)", + "APP_KEY": "str?", + "DB_DATABASE": "str?", + "DB_HOST": "str?", + "DB_PASSWORD": "str?", + "DB_PORT": "int?", + "DB_USERNAME": "str?", + "MAIL_MAILER": "str?", + "MAIL_HOST": "str?", + "MAIL_PORT": "str?", + "MAIL_USERNAME": "str?", + "MAIL_PASSWORD": "str?", + "MAIL_ENCRYPTION": "str?", + "MAIL_FROM_ADDRESS": "str?", + "MAIL_FROM_NAME": "str?" +} +services: +- mysql:want +slug: grampsweb +tmpfs: true +url: https://github.com/alexbelgium/hassio-addons/tree/master/grampsweb +version: 1.0 +webui: "[PROTO:ssl]://[HOST]:[PORT:80]" diff --git a/grampsweb/icon.png b/grampsweb/icon.png new file mode 100644 index 000000000..16bf9668a Binary files /dev/null and b/grampsweb/icon.png differ diff --git a/grampsweb/logo.png b/grampsweb/logo.png new file mode 100644 index 000000000..16bf9668a Binary files /dev/null and b/grampsweb/logo.png differ diff --git a/grampsweb/rootfs/etc/cont-init.d/99-run.sh b/grampsweb/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..9d4a1f26a --- /dev/null +++ b/grampsweb/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,54 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +set -e + +################# +# Set structure # +################# + + +for folders in users indexdir database secret media cache thumbnail_cache grampsdb; do + mkdir -p /config/"$folders" + if [ -d /app/"$folders" ] && [ "$(ls -A /app/"$folders")" ]; then + cp -rf /app/"$folders"/* /config/"$folders" + fi + rm -rf /app/"$folders" + ln -sf /config/"$folders" /app/"$folders" +done + +if [ -d /root/.gramps/grampsdb ] && [ "$(ls -A /root/.gramps/grampsdb)" ]; then + cp -rf /root/.gramps/grampsdb/* /config/grampsdb + rm -rf /root/.gramps/grampsdb + ln -sf /config/grampsdb /root/.gramps/grampsdb +fi + +################## +# Starting Redis # +################## +echo "Starting Redis..." +redis-server & +REDIS_PID=$! + +################## +# Starting Celery # +################## +echo "Starting Celery..." +celery -A gramps_webapi.celery worker --loglevel=INFO --concurrency=2 & +CELERY_PID=$! + +################# +# Staring nginx # +################# +echo "Starting nginx..." +exec nginx & bashio::log.info "Starting nginx" +NGINX_PID=$! + +############### +# Starting App # +############### +echo "Starting Gramps Web App..." +/docker-entrypoint.sh gunicorn -w ${GUNICORN_NUM_WORKERS:-8} -b 0.0.0.0:5000 gramps_webapi.wsgi:app --timeout ${GUNICORN_TIMEOUT:-120} --limit-request-line 8190 & +APP_PID=$! + +# Wait for all background processes +wait $REDIS_PID $CELERY_PID $APP_PID $NGINX_PID diff --git a/grampsweb/stats.png b/grampsweb/stats.png new file mode 100644 index 000000000..7ab8655bc Binary files /dev/null and b/grampsweb/stats.png differ diff --git a/grampsweb/updater.json b/grampsweb/updater.json new file mode 100644 index 000000000..e6e8b760b --- /dev/null +++ b/grampsweb/updater.json @@ -0,0 +1,9 @@ +{ + "github_beta": true, + "github_tagfilter": "v5", + "last_update": "07-12-2024", + "repository": "alexbelgium/hassio-addons", + "slug": "grampsweb", + "upstream_repo": "grampswebhq/grampsweb", + "upstream_version": "" +}