Docker: use tini as init system (#72)

This commit is contained in:
Quentin McGaw 2021-07-16 06:14:02 -07:00 committed by GitHub
parent 2bc7ea9e06
commit d18c045c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -119,12 +119,14 @@ RUN description="$(file /tmp/binary)" && \
FROM alpine:${ALPINE_VERSION} FROM alpine:${ALPINE_VERSION}
EXPOSE 9586/tcp EXPOSE 9586/tcp
WORKDIR /usr/local/bin WORKDIR /usr/local/bin
RUN apk add --no-cache --q tini && \
rm -rf /var/cache/apk/*
RUN adduser prometheus-wireguard-exporter -s /bin/sh -D -u 1000 1000 && \ RUN adduser prometheus-wireguard-exporter -s /bin/sh -D -u 1000 1000 && \
mkdir -p /etc/sudoers.d && \ mkdir -p /etc/sudoers.d && \
echo 'prometheus-wireguard-exporter ALL=(root) NOPASSWD:/usr/bin/wg show * dump' > /etc/sudoers.d/prometheus-wireguard-exporter && \ echo 'prometheus-wireguard-exporter ALL=(root) NOPASSWD:/usr/bin/wg show * dump' > /etc/sudoers.d/prometheus-wireguard-exporter && \
chmod 0440 /etc/sudoers.d/prometheus-wireguard-exporter chmod 0440 /etc/sudoers.d/prometheus-wireguard-exporter
RUN apk add --update -q --no-cache wireguard-tools-wg sudo RUN apk add --update -q --no-cache wireguard-tools-wg sudo
USER prometheus-wireguard-exporter USER prometheus-wireguard-exporter
ENTRYPOINT [ "/usr/local/bin/prometheus_wireguard_exporter" ] ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/prometheus_wireguard_exporter"]
CMD [ "-a" ] CMD [ "-a" ]
COPY --from=build --chown=prometheus-wireguard-exporter /tmp/binary ./prometheus_wireguard_exporter COPY --from=build --chown=prometheus-wireguard-exporter /tmp/binary ./prometheus_wireguard_exporter

View file

@ -45,7 +45,7 @@ Coming soon, subcribe to [#59](https://github.com/MindFlavor/prometheus_wireguar
1. Download and run the container with: 1. Download and run the container with:
```sh ```sh
docker run -d --init --net=host --cap-add=NET_ADMIN --name wgexporter mindflavor/prometheus-wireguard-exporter docker run -d --net=host --cap-add=NET_ADMIN --name wgexporter mindflavor/prometheus-wireguard-exporter
``` ```
1. Check it's up by visiting [http://localhost:9586/metrics](http://localhost:9586/metrics) 1. Check it's up by visiting [http://localhost:9586/metrics](http://localhost:9586/metrics)