Files
secondo-docker/Dockerfile
2026-01-23 16:46:56 +08:00

88 lines
3.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 1. 基础镜像
FROM ubuntu:20.04
# 2. 预备环境 (为了能跑通 InstallSDK 脚本)
# 设置非交互模式,防止 apt 卡住
ENV DEBIAN_FRONTEND=noninteractive
# 安装运行 InstallSDK 脚本所需的“最小”前置工具
# - sudo: 脚本里通常有 sudo 命令
# - unzip: 解压你的源码包
# - lsb-release: 脚本可能会检测系统版本
# - file/wget: 脚本常用的工具
RUN apt-get update && apt-get install -y \
sudo \
unzip \
lsb-release \
file \
wget \
nano \
&& rm -rf /var/lib/apt/lists/*
# 3. 准备文件
WORKDIR /root
# 复制源码包和安装脚本
COPY secondo-RC_430.zip .
COPY InstallSDK_Ubuntu_20_04.bash .
# 4. 解压源码
# 解压并重命名为 secondo (模拟你物理机上的 /home/db/secondo)
RUN unzip -q secondo-RC_430.zip \
&& mv secondo-RC_430 secondo \
&& rm secondo-RC_430.zip
# 5. 【核心步骤】确保无交互地安装系统包并执行官方安装脚本
# 预置时区(避免 tzdata 在构建时弹出交互式选择)并以非交互模式运行安装脚本
RUN ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata && \
dpkg-reconfigure -f noninteractive tzdata && \
rm -rf /var/lib/apt/lists/*
# 以非交互模式运行官方安装脚本(脚本内部使用 apt-get -y 已包含,但某些包仍会触发 debconf
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC bash InstallSDK_Ubuntu_20_04.bash
# 6. 配置环境加载方式
# 脚本运行完会生成 /root/.secondorc
# 我们将它写入 .bashrc这样你进入容器交互时环境是好的
RUN echo "source /root/.secondorc /root/secondo" >> /root/.bashrc
# 7. 源码补丁 (这是必须要做的,因为脚本只负责装环境,不负责修源码里的 GCC 13 错误)
WORKDIR /root/secondo
# [修复权限] 对应你物理机的 chmod 操作
RUN chmod -R +x .
# [修复 GCC 13] 去掉 -Werror否则编译必挂
# RUN find . -name "makefile*" -print0 | xargs -0 sed -i 's/-Werror//g'
# [修复 API] 跳过 API 编译,防止链接错误
# RUN sed -i '/API/d' makefile && \
# sed -i 's/update-config \\/update-config/' makefile
# 8. 编译 Secondo
# 切换 Docker 的默认 Shell 为 bash否则 source 命令无法使用
SHELL ["/bin/bash", "-c"]
# 关键:先 source 脚本生成的配置,再编译!
# 这样 make 就能读到 InstallSDK 设置的所有变量
RUN source /root/.secondorc /root/secondo && \
make clean && \
make
# 10. 安装并配置 SSH复制 entrypoint 脚本并暴露端口
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && \
mkdir -p /var/run/sshd && \
echo 'root:123' | chpasswd && \
sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config || true && \
sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config || true && \
rm -rf /var/lib/apt/lists/*
# 复制并赋予 entrypoint 可执行权限entrypoint 启动 sshd 并启动 SecondoListener
COPY entrypoint.sh /root/entrypoint.sh
RUN chmod +x /root/entrypoint.sh
EXPOSE 1234 22
# 容器启动时运行 entrypoint先启动 sshd再 source .secondorc 并 exec SecondoListener
CMD ["/root/entrypoint.sh"]