From 67d027f49f299ecb77cd6b884f6a42bd407f2471 Mon Sep 17 00:00:00 2001 From: jihaofeng <1343277221@qq.com> Date: Sat, 14 Sep 2024 14:08:33 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]etcd=E3=80=81node-exporter?= =?UTF-8?q?=E3=80=81prometheus=E7=9A=84dockerfile=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 11 ++------- docker/etcd/Dockerfile | 19 ++++++++++++++-- docker/node_exporter/Dockerfile | 23 ++++++++++++++----- docker/prometheus/Dockerfile | 40 +++++++++++++++++++++++++-------- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a76caf1..4876e21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,13 +4,6 @@ services: ports: - 2379:2379 - 2380:2370 - confd: - build: docker/confd - depends_on: - - etcd - volumes: - - ./confd:/etc/confd - - ./data:/data prometheus: build: docker/prometheus ports: @@ -31,5 +24,5 @@ services: build: docker/node_exporter opcua-exporter: build: opcua-exporter - volumes: - - ./data:/data \ No newline at end of file +## volumes: +## - ./data:/data \ No newline at end of file diff --git a/docker/etcd/Dockerfile b/docker/etcd/Dockerfile index f3c0acf..d01f25c 100644 --- a/docker/etcd/Dockerfile +++ b/docker/etcd/Dockerfile @@ -1,13 +1,28 @@ FROM openeuler/openeuler:24.03 +# 根据平台执行不同的安装步骤 +RUN architecture=$(uname -m); \ + if [ "$architecture" = "aarch64" ]; then \ + echo "install ARM64 ETCD"; \ + elif [ "$architecture" = "x86_64" ]; then \ + echo "install x86_64 ETCD"; \ + else \ + echo "platform [$architecture] not support"; \ + exit 1; \ + fi + +# 安装和清理 RUN dnf update -y \ && dnf install etcd -y \ && dnf clean all \ && rm -rf /var/cache/dnf/* +# 设置环境变量 ENV ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" \ -ETCD_ADVERTISE_CLIENT_URLS="http://127.0.0.1:2379" + ETCD_ADVERTISE_CLIENT_URLS="http://127.0.0.1:2379" +# 暴露端口 EXPOSE 2379 2380 -CMD ["etcd"] \ No newline at end of file +# 运行 etcd +CMD ["etcd"] diff --git a/docker/node_exporter/Dockerfile b/docker/node_exporter/Dockerfile index bbe9894..92c47b1 100644 --- a/docker/node_exporter/Dockerfile +++ b/docker/node_exporter/Dockerfile @@ -3,10 +3,23 @@ FROM openeuler/openeuler:24.03 RUN dnf update -y && \ dnf clean all && \ rm -rf /var/cache/dnf/* - -RUN curl -fsSL https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ - mv /usr/local/bin/node_exporter-*/node_exporter /usr/local/bin/node_exporter && \ - rm /usr/local/bin/node_exporter-* -rf && \ - chmod +x /usr/local/bin/node_exporter +# 根据平台执行不同的安装步骤 +RUN architecture=$(uname -m); \ + if [ "$architecture" = "aarch64" ]; then \ + echo "install ARM64 node_exporter"; \ + curl -fsSL https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-arm64.tar.gz | tar -xz -C /usr/local/bin && \ + mv /usr/local/bin/node_exporter-*/node_exporter /usr/local/bin/node_exporter && \ + rm /usr/local/bin/node_exporter-* -rf && \ + chmod +x /usr/local/bin/node_exporter; \ + elif [ "$architecture" = "x86_64" ]; then \ + echo "install x86_64 node_exporter"; \ + curl -fsSL https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ + mv /usr/local/bin/node_exporter-*/node_exporter /usr/local/bin/node_exporter && \ + rm /usr/local/bin/node_exporter-* -rf && \ + chmod +x /usr/local/bin/node_exporter; \ + else \ + echo "Platform [$architecture] not supported"; \ + exit 1; \ + fi CMD ["node_exporter"] \ No newline at end of file diff --git a/docker/prometheus/Dockerfile b/docker/prometheus/Dockerfile index 41b5da0..f7f97b8 100644 --- a/docker/prometheus/Dockerfile +++ b/docker/prometheus/Dockerfile @@ -1,24 +1,46 @@ FROM openeuler/openeuler:24.03 RUN dnf update -y && \ + dnf install -y supervisor && \ dnf clean all && \ - dnf install -y supervisor &&\ rm -rf /var/cache/dnf/* -RUN curl -fsSL https://github.com/prometheus/prometheus/releases/download/v2.54.0/prometheus-2.54.0.linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ - mv /usr/local/bin/prometheus-*/prometheus /usr/local/bin/prometheus && \ - rm /usr/local/bin/prometheus-* -rf && \ - chmod +x /usr/local/bin/prometheus +RUN architecture=$(uname -m); \ + if [ "$architecture" = "aarch64" ]; then \ + echo "install ARM64 prometheus"; \ + curl -fsSL --retry 3 https://github.com/prometheus/prometheus/releases/download/v2.54.0/prometheus-2.54.0.linux-arm64.tar.gz | tar -xz -C /usr/local/bin && \ + mv /usr/local/bin/prometheus-*/prometheus /usr/local/bin/prometheus && \ + rm /usr/local/bin/prometheus-* -rf && \ + chmod +x /usr/local/bin/prometheus; \ + elif [ "$architecture" = "x86_64" ]; then \ + echo "install x86_64 prometheus"; \ + curl -fsSL --retry 3 https://github.com/prometheus/prometheus/releases/download/v2.54.0/prometheus-2.54.0.linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ + mv /usr/local/bin/prometheus-*/prometheus /usr/local/bin/prometheus && \ + rm /usr/local/bin/prometheus-* -rf && \ + chmod +x /usr/local/bin/prometheus; \ + else \ + echo "platform [$architecture] not supported"; \ + exit 1; \ + fi -RUN curl -fsSL https://github.com/abtreece/confd/releases/download/v0.20.0/confd-v0.20.0-linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ - chmod +x /usr/local/bin/confd +RUN architecture=$(uname -m); \ + if [ "$architecture" = "aarch64" ]; then \ + echo "install ARM64 confd"; \ + curl -fsSL --retry 3 https://github.com/abtreece/confd/releases/download/v0.20.0/confd-v0.20.0-linux-arm64.tar.gz | tar -xz -C /usr/local/bin && \ + chmod +x /usr/local/bin/confd; \ + elif [ "$architecture" = "x86_64" ]; then \ + echo "install x86_64 confd"; \ + curl -fsSL --retry 3 https://github.com/abtreece/confd/releases/download/v0.20.0/confd-v0.20.0-linux-amd64.tar.gz | tar -xz -C /usr/local/bin && \ + chmod +x /usr/local/bin/confd; \ + else \ + echo "platform [$architecture] not supported"; \ + exit 1; \ + fi RUN mkdir /etc/prometheus/ COPY ./confd/ /etc/confd/ - COPY prometheus.yml /etc/prometheus/prometheus.yml - COPY ./supervisord/ /etc/supervisord/ CMD [ "supervisord", "-c", "/etc/supervisord/supervisord.conf" ]