This commit is contained in:
ElevenNotes
2023-06-06 15:14:35 +02:00
parent a0179d911f
commit 350d41896f
3 changed files with 59 additions and 51 deletions

View File

@@ -1,18 +1,20 @@
# Info
The plugin-driven server agent for collecting & reporting metrics.
This container provides an easy and simple way to use telegraf without the hassle of library dependencies and compiling the source yourself.
## Volumes
None
# Alpine :: Telegraf
Run Nodejs based on Alpine Linux. Small, lightweight, secure and fast 🏔️
## Run
```shell
docker run --name telegraf \
-v /.../telegraf.conf:/telegraf/etc/telegraf.conf:ro \
-d 11notes/telegraf:[tag]
-v /.../telegraf.conf:/telegraf/etc/telegraf.conf:ro \
-d 11notes/telegraf:[tag]
```
## Defaults
| Parameter | Value | Description |
| --- | --- | --- |
| `user` | docker | user docker |
| `uid` | 1000 | user id 1000 |
| `gid` | 1000 | group id 1000 |
# Examples telegraf.conf
```shell
[agent]
@@ -36,6 +38,13 @@ docker run --name telegraf \
urls = ["http://localhost:8080/metrics"]
```
## Build with
* [telegraf](https://github.com/influxdata/telegraf) - Telegraf
* [Alpine Linux](https://alpinelinux.org/) - Alpine Linux
## Parent
* [11notes/alpine:stable](https://github.com/11notes/docker-alpine)
## Built with
* [telegraf](https://github.com/influxdata/telegraf)
* [Alpine Linux](https://alpinelinux.org/)
## Tips
* Don't bind to ports < 1024 (requires root), use NAT/reverse proxy
* [Permanent Stroage](https://github.com/11notes/alpine-docker-netshare) - Module to store permanent container data via NFS/CIFS and more

View File

@@ -1,46 +1,45 @@
# :: Build
FROM golang:alpine as telegraf
ENV checkout=v1.26.1
FROM golang:alpine as build
ENV checkout=v1.26.3
RUN set -ex; \
apk add --update --no-cache \
make \
git; \
git clone https://github.com/influxdata/telegraf.git; \
cd /go/telegraf; \
git checkout ${checkout}; \
make build -j $(nproc); \
mv telegraf /usr/local/bin;
RUN set -ex; \
apk add --update --no-cache \
make \
git; \
git clone https://github.com/influxdata/telegraf.git; \
cd /go/telegraf; \
git checkout ${checkout}; \
make build -j $(nproc); \
mv telegraf /usr/local/bin;
# :: Header
FROM alpine:latest
COPY --from=telegraf /usr/local/bin/ /usr/local/bin
FROM 11notes/alpine:stable
COPY --from=build /usr/local/bin/ /usr/local/bin
# :: Run
USER root
# :: Run
USER root
# :: prepare
RUN set -ex; \
mkdir -p /telegraf; \
mkdir -p /telegraf/etc;
# :: update image
RUN set -ex; \
apk update; \
apk upgrade;
RUN set -ex; \
apk add --update --no-cache \
shadow;
# :: prepare image
RUN set -ex; \
mkdir -p /telegraf; \
mkdir -p /telegraf/etc;
RUN set -ex; \
addgroup --gid 1000 -S telegraf; \
adduser --uid 1000 -D -S -h /telegraf -s /sbin/nologin -G telegraf telegraf;
# :: copy root filesystem changes and add execution rights to init scripts
COPY ./rootfs /
RUN set -ex; \
chmod +x -R /usr/local/bin;
# :: copy root filesystem changes
COPY ./rootfs /
# :: docker -u 1000:1000 (no root initiative)
RUN set -ex; \
chown -R telegraf:telegraf \
/telegraf
# :: change home path for existing user and set correct permission
RUN set -ex; \
usermod -d /telegraf docker; \
chown -R 1000:1000 \
/telegraf;
# :: Start
RUN set -ex; chmod +x /usr/local/bin/entrypoint.sh
USER telegraf
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
USER docker
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

View File

@@ -1,7 +1,7 @@
#!/bin/ash
if [ -z "${1}" ]; then
if [ -z "${1}" ]; then
set -- "telegraf" \
--config /telegraf/etc/telegraf.conf
fi
--config /telegraf/etc/telegraf.conf
fi
exec "$@"
exec "$@"