mirror of
https://github.com/hassio-addons/addon-prometheus.git
synced 2025-05-04 19:21:35 +00:00
fix: make Prometheus run as root
Following guidance in https://github.com/hassio-addons/addon-prometheus/pull/49#discussion_r926048521. Tested in local dev container.
This commit is contained in:
parent
84aa6d580e
commit
d0e295dc83
3 changed files with 2 additions and 8 deletions
|
@ -30,7 +30,6 @@ RUN \
|
||||||
\
|
\
|
||||||
&& curl -J -L -o /tmp/prometheus.tar.gz \
|
&& curl -J -L -o /tmp/prometheus.tar.gz \
|
||||||
"https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}.tar.gz" \
|
"https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}.tar.gz" \
|
||||||
&& adduser -s /bin/false -D -H prometheus \
|
|
||||||
&& cd /tmp \
|
&& cd /tmp \
|
||||||
&& tar -xvf /tmp/prometheus.tar.gz \
|
&& tar -xvf /tmp/prometheus.tar.gz \
|
||||||
&& mkdir -p /etc/prometheus \
|
&& mkdir -p /etc/prometheus \
|
||||||
|
@ -39,7 +38,6 @@ RUN \
|
||||||
&& cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/console_libraries/ /etc/prometheus/ \
|
&& cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/console_libraries/ /etc/prometheus/ \
|
||||||
&& cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/consoles/ /etc/prometheus/ \
|
&& cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/consoles/ /etc/prometheus/ \
|
||||||
&& rm -r prometheus-${PROMETHEUS_VERSION}.linux-${ARCH} \
|
&& rm -r prometheus-${PROMETHEUS_VERSION}.linux-${ARCH} \
|
||||||
&& chown -R prometheus:prometheus /etc/prometheus \
|
|
||||||
&& pip3 install \
|
&& pip3 install \
|
||||||
--no-cache-dir \
|
--no-cache-dir \
|
||||||
--prefer-binary \
|
--prefer-binary \
|
||||||
|
|
|
@ -3,11 +3,10 @@ bashio::log.info 'Starting prometheus config generator...'
|
||||||
|
|
||||||
if ! bashio::fs.directory_exists /share/prometheus/targets; then
|
if ! bashio::fs.directory_exists /share/prometheus/targets; then
|
||||||
mkdir -p /share/prometheus/targets
|
mkdir -p /share/prometheus/targets
|
||||||
chown -R prometheus:prometheus /share/prometheus/targets
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /opt/prometheus-configgen || bashio::exit.nok \
|
cd /opt/prometheus-configgen || bashio::exit.nok \
|
||||||
"Could not change working directory for prometheus-configgen."
|
"Could not change working directory for prometheus-configgen."
|
||||||
|
|
||||||
# Run Prometheus
|
# Run Prometheus
|
||||||
exec s6-setuidgid prometheus python3 combiner
|
exec python3 combiner
|
||||||
|
|
|
@ -28,18 +28,15 @@ done
|
||||||
|
|
||||||
if ! bashio::fs.directory_exists /data/prometheus; then
|
if ! bashio::fs.directory_exists /data/prometheus; then
|
||||||
mkdir -p /data/prometheus
|
mkdir -p /data/prometheus
|
||||||
chown prometheus:prometheus /data/prometheus
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! bashio::fs.directory_exists /share/prometheus/rules; then
|
if ! bashio::fs.directory_exists /share/prometheus/rules; then
|
||||||
mkdir -p /share/prometheus/rules
|
mkdir -p /share/prometheus/rules
|
||||||
chown -R prometheus:prometheus /share/prometheus/rules
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! bashio::fs.directory_exists /share/prometheus/targets; then
|
if ! bashio::fs.directory_exists /share/prometheus/targets; then
|
||||||
mkdir -p /share/prometheus/targets
|
mkdir -p /share/prometheus/targets
|
||||||
chown -R prometheus:prometheus /share/prometheus/targets
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run Prometheus
|
# Run Prometheus
|
||||||
exec s6-setuidgid prometheus /usr/local/bin/prometheus "${options[@]}"
|
exec /usr/local/bin/prometheus "${options[@]}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue