[优化]etcd、node-exporter、prometheus的dockerfile部署优化

This commit is contained in:
2024-09-14 14:08:33 +08:00
committed by Coding
parent 9243c4a797
commit 67d027f49f
4 changed files with 68 additions and 25 deletions

View File

@@ -4,13 +4,6 @@ services:
ports: ports:
- 2379:2379 - 2379:2379
- 2380:2370 - 2380:2370
confd:
build: docker/confd
depends_on:
- etcd
volumes:
- ./confd:/etc/confd
- ./data:/data
prometheus: prometheus:
build: docker/prometheus build: docker/prometheus
ports: ports:
@@ -31,5 +24,5 @@ services:
build: docker/node_exporter build: docker/node_exporter
opcua-exporter: opcua-exporter:
build: opcua-exporter build: opcua-exporter
volumes: ## volumes:
- ./data:/data ## - ./data:/data

View File

@@ -1,13 +1,28 @@
FROM openeuler/openeuler:24.03 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 \ RUN dnf update -y \
&& dnf install etcd -y \ && dnf install etcd -y \
&& dnf clean all \ && dnf clean all \
&& rm -rf /var/cache/dnf/* && rm -rf /var/cache/dnf/*
# 设置环境变量
ENV ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379" \ 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 EXPOSE 2379 2380
# 运行 etcd
CMD ["etcd"] CMD ["etcd"]

View File

@@ -3,10 +3,23 @@ FROM openeuler/openeuler:24.03
RUN dnf update -y && \ RUN dnf update -y && \
dnf clean all && \ dnf clean all && \
rm -rf /var/cache/dnf/* 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 && \ RUN architecture=$(uname -m); \
mv /usr/local/bin/node_exporter-*/node_exporter /usr/local/bin/node_exporter && \ if [ "$architecture" = "aarch64" ]; then \
rm /usr/local/bin/node_exporter-* -rf && \ echo "install ARM64 node_exporter"; \
chmod +x /usr/local/bin/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"] CMD ["node_exporter"]

View File

@@ -1,24 +1,46 @@
FROM openeuler/openeuler:24.03 FROM openeuler/openeuler:24.03
RUN dnf update -y && \ RUN dnf update -y && \
dnf install -y supervisor && \
dnf clean all && \ dnf clean all && \
dnf install -y supervisor &&\
rm -rf /var/cache/dnf/* 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 && \ RUN architecture=$(uname -m); \
mv /usr/local/bin/prometheus-*/prometheus /usr/local/bin/prometheus && \ if [ "$architecture" = "aarch64" ]; then \
rm /usr/local/bin/prometheus-* -rf && \ echo "install ARM64 prometheus"; \
chmod +x /usr/local/bin/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 && \ RUN architecture=$(uname -m); \
chmod +x /usr/local/bin/confd 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/ RUN mkdir /etc/prometheus/
COPY ./confd/ /etc/confd/ COPY ./confd/ /etc/confd/
COPY prometheus.yml /etc/prometheus/prometheus.yml COPY prometheus.yml /etc/prometheus/prometheus.yml
COPY ./supervisord/ /etc/supervisord/ COPY ./supervisord/ /etc/supervisord/
CMD [ "supervisord", "-c", "/etc/supervisord/supervisord.conf" ] CMD [ "supervisord", "-c", "/etc/supervisord/supervisord.conf" ]