45 lines
1.5 KiB
Docker
45 lines
1.5 KiB
Docker
FROM docker.elastic.co/elasticsearch/elasticsearch:8.13.4
|
|
|
|
# 切换到 root 用户进行系统级安装
|
|
USER root
|
|
|
|
# 设置构建参数
|
|
ARG USE_INTRANET=false
|
|
|
|
# 配置内网 apt 源 (如果指定了内网选项)
|
|
RUN if [ "$USE_INTRANET" = "true" ]; then \
|
|
echo "Configuring intranet apt sources..." && \
|
|
cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
|
|
echo "deb [trusted=yes] http://10.68.64.1/ubuntu2204/ jammy main" > /etc/apt/sources.list && \
|
|
echo 'Acquire::https::Verify-Peer "false";' > /etc/apt/apt.conf.d/99disable-ssl-check && \
|
|
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99disable-ssl-check; \
|
|
fi
|
|
|
|
# 安装 supervisor
|
|
RUN apt-get update && \
|
|
apt-get install -y supervisor && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# 创建 supervisor 日志目录
|
|
RUN mkdir -p /var/log/supervisor
|
|
|
|
# 复制 supervisor 配置文件
|
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
|
|
|
# 复制启动脚本
|
|
COPY start-es-supervised.sh /usr/local/bin/start-es-supervised.sh
|
|
RUN chmod +x /usr/local/bin/start-es-supervised.sh
|
|
|
|
# 创建数据目录并设置权限
|
|
RUN mkdir -p /private/argus/log/elasticsearch && \
|
|
chown -R elasticsearch:elasticsearch /private/argus/log/elasticsearch
|
|
|
|
# 保持 root 用户,由 supervisor 管理用户切换
|
|
USER root
|
|
|
|
# 暴露端口
|
|
EXPOSE 9200 9300
|
|
|
|
# 使用 supervisor 作为入口点
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |