This commit is contained in:
2023-08-25 03:48:12 +02:00
parent 914507cb52
commit 4217b38853
2 changed files with 43 additions and 61 deletions

View File

@@ -3,6 +3,12 @@ FROM ${BUILD_FROM}
# Build arguments # Build arguments
ARG BUILD_ARCH ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
ARG YQ_VERSION ARG YQ_VERSION
ARG PROMTAIL_VERSION ARG PROMTAIL_VERSION
@@ -15,7 +21,6 @@ RUN set -eux; \
unzip \ unzip \
; \ ; \
update-ca-certificates; \ update-ca-certificates; \
\
case "${BUILD_ARCH}" in \ case "${BUILD_ARCH}" in \
amd64) BINARCH='amd64' ;; \ amd64) BINARCH='amd64' ;; \
armhf) BINARCH='arm' ;; \ armhf) BINARCH='arm' ;; \
@@ -37,24 +42,14 @@ RUN set -eux; \
unzip /tmp/promtail.zip -d /usr/bin; \ unzip /tmp/promtail.zip -d /usr/bin; \
mv /usr/bin/promtail-linux-${BINARCH} /usr/bin/promtail; \ mv /usr/bin/promtail-linux-${BINARCH} /usr/bin/promtail; \
chmod +x /usr/bin/promtail; \ chmod +x /usr/bin/promtail; \
rm /tmp/promtail.zip rm /tmp/promtail.zip; \
mkdir -p /data/promtail
COPY rootfs / COPY rootfs /
WORKDIR /data/promtail WORKDIR /data/promtail
COPY s6-overlay /package/admin/s6-overlay-3.1.5.0/ COPY s6-overlay /package/admin/s6-overlay-3.1.5.0/
# Build arguments
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_DESCRIPTION
ARG BUILD_NAME
ARG BUILD_REF
ARG BUILD_REPOSITORY
ARG BUILD_VERSION
USER root
# Labels # Labels
LABEL \ LABEL \
io.hass.name="${BUILD_NAME}" \ io.hass.name="${BUILD_NAME}" \
@@ -62,4 +57,12 @@ LABEL \
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="fbonelle" maintainer="fbonelle" \
org.opencontainers.image.title="${BUILD_NAME}" \
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
org.opencontainers.image.vendor="fbonelle's addons" \
org.opencontainers.image.authors="fbonelle" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REF} \
org.opencontainers.image.version=${BUILD_VERSION}

View File

@@ -1,58 +1,37 @@
include <tunables/global> #include <tunables/global>
# Docker overlay
@{docker_root}=/docker/ /var/lib/docker/
@{fs_root}=/ @{docker_root}/overlay2/*/diff/
@{do_etc}=@{fs_root}/etc/
@{do_opt}=@{fs_root}/opt/
@{do_run}=@{fs_root}/{run,var/run}/
@{do_usr}=@{fs_root}/usr/
@{do_var}=@{fs_root}/var/
# Systemd Journal location # Systemd Journal location
@{journald}=/{run,var}/log/journal/{,**} @{journald}=/{run,var}/log/journal/{,**}
profile promtail flags=(attach_disconnected,mediate_deleted) { profile promtail flags=(attach_disconnected,mediate_deleted) {
include <abstractions/base> #include <abstractions/base>
include <abstractions/bash>
# Send signals to child services # Capabilities
signal (send) peer=@{profile_name}//*, file,
signal (send) set=(kill,term,int,hup,cont),
# Network access # Network access
network tcp, network tcp,
network udp, network udp,
# S6-Overlay # S6-Overlay
/init rix, /init ix,
/bin/** rix, /bin/** ix,
/usr/bin/** rix, /usr/bin/** ix,
@{do_etc}/s6*/** r, /run/{s6,s6-rc*,service}/** ix,
@{do_etc}/fix-attrs.d/{,**} r, /package/** ix,
@{do_etc}/cont-{init,finish}.d/{,**} rwix, /command/** ix,
@{do_etc}/services.d/{,**} rwix, /etc/services.d/** rwix,
@{do_run}/{s6,s6-rc*,service}/** rix, /etc/cont-init.d/** rwix,
/command/** rix, /etc/cont-finish.d/** rwix,
/package/** rix, /run/{,**} rwk,
@{do_run}/{,**} rwk,
/dev/tty rw, /dev/tty rw,
@{do_usr}/lib/locale/{,**} r,
@{do_etc}/ssl/openssl.cnf r,
@{do_etc}/{group,hosts,passwd} r,
@{do_etc}/{host,nsswitch,resolv}.conf r,
/dev/null k,
# https://github.com/hassio-addons/addon-debian-base/blob/main/base/rootfs/etc/cont-init.d/02-set-timezone.sh
# Wants to link /etc/localtime but apparmor sees a random hash so * it is.
@{do_etc}/* rw,
@{do_usr}/share/zoneinfo/{,**} r,
# Bashio # Bashio
/usr/lib/bashio/** ix, /usr/lib/bashio/** ix,
/tmp/** rw, /tmp/** rwk,
# Options.json & addon data # Access to options.json and other files within your addon
/data r,
/data/** rw, /data/** rw,
# Files needed for setup # Files needed for setup
@@ -61,11 +40,11 @@ profile promtail flags=(attach_disconnected,mediate_deleted) {
/{share,ssl}/{,**} r, /{share,ssl}/{,**} r,
@{journald} r, @{journald} r,
# Programs # Start new profile for service
/usr/bin/promtail cx -> promtail, /usr/bin/promtail cx -> promtail_profile,
/usr/bin/yq Cx, /usr/bin/yq cx -> yq_profile,
profile promtail flags=(attach_disconnected,mediate_deleted) { profile promtail_profile flags=(attach_disconnected,mediate_deleted) {
include <abstractions/base> include <abstractions/base>
# Receive signals from s6 # Receive signals from s6
@@ -100,7 +79,7 @@ profile promtail flags=(attach_disconnected,mediate_deleted) {
@{do_etc}/ssl/certs/** r, @{do_etc}/ssl/certs/** r,
} }
profile /usr/bin/yq flags=(attach_disconnected,mediate_deleted) { profile yq_profile flags=(attach_disconnected,mediate_deleted) {
include <abstractions/base> include <abstractions/base>
# Config files # Config files