diff --git a/linkwarden/Dockerfile b/linkwarden/Dockerfile new file mode 100644 index 000000000..99a753c97 --- /dev/null +++ b/linkwarden/Dockerfile @@ -0,0 +1,114 @@ +#============================# +# ALEXBELGIUM'S DOCKERFILE # +#============================# +# _.------. +# _.-` ('>.-`"""-. +# '.--'` _'` _ .--.) +# -' '-.-';` ` +# ' - _.' ``'--. +# '---` .-'""` +# /` +#=== Home Assistant Addon ===# + +################# +# 1 Build Image # +################# + +ARG BUILD_VERSION +FROM ${BUILD_FROM} +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Adapt for SQLITE +RUN \ + sed -i "s|postgresql|sqlite|g" /prisma/schema.prisma + +################## +# 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 + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# 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="" + +# 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 + +# +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/ha_entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 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="80" \ + 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/linkwarden/apparmor.txt b/linkwarden/apparmor.txt new file mode 100644 index 000000000..7417d344e --- /dev/null +++ b/linkwarden/apparmor.txt @@ -0,0 +1,66 @@ +#include + +profile linkwarden_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/linkwarden/build.yaml b/linkwarden/build.yaml new file mode 100644 index 000000000..5e2ff772f --- /dev/null +++ b/linkwarden/build.yaml @@ -0,0 +1,6 @@ +--- +build_from: + aarch64: ghcr.io/linkwarden/linkwarden:main + amd64: ghcr.io/linkwarden/linkwarden:main +codenotary: + signer: alexandrep.github@gmail.com diff --git a/linkwarden/config.json b/linkwarden/config.json new file mode 100644 index 000000000..f4fae75e5 --- /dev/null +++ b/linkwarden/config.json @@ -0,0 +1,33 @@ +{ + "arch": [ + "aarch64", + "amd64" + ], + "codenotary": "alexandrep.github@gmail.com", + "description": "collaborative bookmark manager to collect, organize, and preserve webpages and articles", + "environment": { + "DATABASE_URL": "/config/linkwarden.sqlite", + "NEXTAUTH_URL": "http://localhost:3000/api/v1/auth", + "STORAGE_FOLDER": "/config" + }, + "init": false, + "map": [ + "addon_config:rw" + ], + "name": "Linkwarden", + "ports": { + "3000/tcp": 3000 + }, + "ports_description": { + "3000/tcp": "linkwarden Vault" + }, + "schema": { + "NEXTAUTH_SECRET": "str", + "NEXTAUTH_URL": "str?" + }, + "slug": "linkwarden", + "udev": true, + "url": "https://github.com/alexbelgium/hassio-addons/tree/master/linkwarden", + "version": "1.0", + "webui": "[PROTO:ssl]://[HOST]:[PORT:3000]" +} diff --git a/linkwarden/rootfs/etc/cont-init.d/99-run.sh b/linkwarden/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..29e58dbd4 --- /dev/null +++ b/linkwarden/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,9 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +set -e + +yarn prisma migrate deploy + +bashio::log.info "Starting app..." + +yarn start docker-entrypoint.sh