-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Build & push vMonitor-Metrics-Agent Docker Image | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
push_to_hub: | ||
description: 'Publish docker image to dockerhub' | ||
required: false | ||
default: false | ||
type: boolean | ||
env: | ||
REPO_NAME: ${{ github.event.repository.name }} | ||
jobs: | ||
build: | ||
name: Build & push docker image | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Create image name env | ||
run: | | ||
echo "IMG_NAME=${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}" >> $GITHUB_ENV | ||
- name: debug | ||
run: | | ||
echo ${{ env.IMG_NAME }} | ||
- name: Docker metadata | ||
id: metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.IMG_NAME }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./docker | ||
push: ${{ inputs.push_to_hub }} | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} | ||
build-alpine: | ||
name: Build & push docker image Alpine | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Create image name env | ||
run: | | ||
echo "IMG_NAME=${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}" >> $GITHUB_ENV | ||
- name: debug | ||
run: | | ||
echo ${{ env.IMG_NAME }} | ||
- name: Docker metadata | ||
id: metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ env.IMG_NAME }} | ||
tags: | | ||
type=semver,pattern={{version}},suffix=-alpine | ||
type=semver,pattern={{major}}.{{minor}},suffix=-alpine | ||
type=raw,value={{sha}}-alpine,enable=${{ github.ref_type != 'tag' }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ vars.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./docker/alpine | ||
push: ${{ inputs.push_to_hub }} | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM buildpack-deps:bullseye-curl | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends iputils-ping snmp procps lm-sensors libcap2-bin && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV TELEGRAF_VERSION 1.26.0-2.0.2 | ||
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" && \ | ||
case "${dpkgArch##*-}" in \ | ||
amd64) ARCH='amd64';; \ | ||
arm64) ARCH='arm64';; \ | ||
armhf) ARCH='armhf';; \ | ||
armel) ARCH='armel';; \ | ||
*) echo "Unsupported architecture: ${dpkgArch}"; exit 1;; \ | ||
esac && \ | ||
wget --no-verbose https://github.com/vngcloud/vmonitor-metrics-agent/releases/download/${TELEGRAF_VERSION}/telegraf_nightly_${ARCH}.deb && \ | ||
dpkg -i telegraf_nightly_${ARCH}.deb && \ | ||
rm -f telegraf_nightly_${ARCH}.deb* | ||
|
||
EXPOSE 8125/udp 8092/udp 8094 | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["telegraf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM alpine:3.17 | ||
|
||
RUN echo 'hosts: files dns' >> /etc/nsswitch.conf | ||
RUN apk add --no-cache iputils ca-certificates net-snmp-tools procps lm_sensors tzdata su-exec libcap && \ | ||
update-ca-certificates | ||
|
||
ENV TELEGRAF_VERSION 1.26.0-2.0.2 | ||
|
||
RUN ARCH= && \ | ||
case "$(apk --print-arch)" in \ | ||
x86_64) ARCH='amd64';; \ | ||
aarch64) ARCH='arm64';; \ | ||
*) echo "Unsupported architecture: $(apk --print-arch)"; exit 1;; \ | ||
esac && \ | ||
set -ex && \ | ||
mkdir ~/.gnupg; \ | ||
echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf; \ | ||
apk add --no-cache --virtual .build-deps wget gnupg tar && \ | ||
wget --no-verbose https://github.com/vngcloud/vmonitor-metrics-agent/releases/download/${TELEGRAF_VERSION}/telegraf-nightly_static_linux_${ARCH}.tar.gz && \ | ||
mkdir -p /usr/src /etc/telegraf && \ | ||
tar -C /usr/src -xzf telegraf-nightly_static_linux_${ARCH}.tar.gz && \ | ||
mv /usr/src/telegraf*/etc/telegraf/telegraf.conf /etc/telegraf/ && \ | ||
mkdir /etc/telegraf/telegraf.d && \ | ||
cp -a /usr/src/telegraf*/usr/bin/telegraf /usr/bin/ && \ | ||
gpgconf --kill all && \ | ||
rm -rf *.tar.gz* /usr/src /root/.gnupg && \ | ||
apk del .build-deps && \ | ||
addgroup -S telegraf && \ | ||
adduser -S telegraf -G telegraf && \ | ||
chown -R telegraf:telegraf /etc/telegraf | ||
|
||
EXPOSE 8125/udp 8092/udp 8094 | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["telegraf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ "$(id -u)" -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec su-exec telegraf "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ $EUID -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec setpriv --reuid telegraf --init-groups "$@" | ||
fi |