[#14] build 构建融合metric镜像,移除测试节点镜像,直接使用基础镜像

This commit is contained in:
2025-10-21 11:20:45 +08:00
parent b0d451cbe7
commit 1d9a8ec695
4 changed files with 94 additions and 28 deletions

View File

@@ -2,6 +2,18 @@ FROM grafana/grafana:11.1.0
USER root
# 构建参数:是否使用内网镜像
ARG USE_INTRANET=false
# 根据是否为内网构建切换 apk 源
RUN if [ "$USE_INTRANET" = "true" ]; then \
echo "Configuring intranet apk repositories..." && \
sed -i 's#https\?://[^/]\+#http://10.68.64.1#g' /etc/apk/repositories; \
else \
echo "Configuring public apk repositories..." && \
sed -i 's#https\?://[^/]\+#https://mirrors.aliyun.com#g' /etc/apk/repositories; \
fi
# 安装必要的工具
RUN apk add --no-cache \
supervisor \
@@ -10,6 +22,11 @@ RUN apk add --no-cache \
vim \
bash
# 部署镜像时恢复到部署侧使用的内网镜像源
RUN if [ "$USE_INTRANET" = "true" ]; then \
sed -i 's#https\?://[^/]\+#https://10.92.132.52/mirrors#g' /etc/apk/repositories; \
fi
# supervisor 日志目录
RUN mkdir -p /var/log/supervisor

View File

@@ -61,10 +61,25 @@ RUN mkdir -p ${PROMETHEUS_BASE_PATH}/rules \
&& ln -s ${PROMETHEUS_BASE_PATH} /prometheus
# 修改 Prometheus 用户 UID/GID 并授权
RUN usermod -u ${ARGUS_BUILD_UID} nobody && \
groupmod -g ${ARGUS_BUILD_GID} nogroup && \
chown -h nobody:nogroup /prometheus && \
chown -R nobody:nogroup ${PROMETHEUS_BASE_PATH} && \
RUN set -eux; \
existing_user=""; \
if getent passwd "${ARGUS_BUILD_UID}" >/dev/null 2>&1; then \
existing_user="$(getent passwd "${ARGUS_BUILD_UID}" | cut -d: -f1)"; \
fi; \
if [ -n "$existing_user" ] && [ "$existing_user" != "nobody" ]; then \
userdel -r "$existing_user" || true; \
fi; \
existing_group=""; \
if getent group "${ARGUS_BUILD_GID}" >/dev/null 2>&1; then \
existing_group="$(getent group "${ARGUS_BUILD_GID}" | cut -d: -f1)"; \
fi; \
if [ -n "$existing_group" ] && [ "$existing_group" != "nogroup" ]; then \
groupdel "$existing_group" || true; \
fi; \
usermod -u ${ARGUS_BUILD_UID} nobody; \
groupmod -g ${ARGUS_BUILD_GID} nogroup; \
chown -h nobody:nogroup /prometheus; \
chown -R nobody:nogroup ${PROMETHEUS_BASE_PATH}; \
chown -R nobody:nogroup /etc/prometheus
# supervisor 配置