refactor: simplify Dockerfile setup and remove arm64-specific configurations

This commit is contained in:
xiao 2025-03-08 22:32:07 +08:00
parent b1ffa8935a
commit 006419e091
4 changed files with 6 additions and 192 deletions

View File

@ -6,12 +6,17 @@ RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debi
&& apt install -y \ && apt install -y \
locales \ locales \
wget iproute2 openssh-server cmake make gcc g++ autoconf sudo curl dos2unix build-essential \ wget iproute2 openssh-server cmake make gcc g++ autoconf sudo curl dos2unix build-essential \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8 \
&& apt autoremove -y \ && apt autoremove -y \
&& apt clean \ && apt clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 复制脚本 # 复制脚本,设置环境变量
COPY ["bt.sh", "init_mysql.sh", "/"] COPY ["bt.sh", "init_mysql.sh", "/"]
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# 转换启动脚本 # 转换启动脚本
RUN dos2unix /bt.sh && dos2unix /init_mysql.sh RUN dos2unix /bt.sh && dos2unix /init_mysql.sh

View File

@ -1,53 +0,0 @@
FROM debian:bookworm
# 切换 Debian 镜像源为腾讯云源,更新包列表并安装依赖
RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources \
&& apt update && apt upgrade -y \
&& apt install -y \
locales \
wget openssh-server cmake make gcc g++ autoconf sudo curl dos2unix build-essential \
&& apt autoremove -y \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# 复制脚本
COPY ["bt.sh", "init_mysql.sh", "/"]
# 转换启动脚本
RUN dos2unix /bt.sh && dos2unix /init_mysql.sh
# 下载并安装宝塔面板及 lnmp 环境
RUN curl -sSO https://download.bt.cn/install/install_panel.sh \
&& echo y | bash install_panel.sh -P 8888 --ssl-disable \
&& btpip config set global.index-url https://mirrors.tencent.com/pypi/simple \
&& mkdir /lnmp \
&& curl -o /lnmp/nginx.sh https://download.bt.cn/install/3/nginx.sh \
&& bash /lnmp/nginx.sh install openresty \
&& rm -rf /lnmp \
&& rm -rf /www/server/nginx/src \
&& echo "docker_bt_nas" > /www/server/panel/data/o.pl \
&& echo '["memuA", "memuAsite", "memuAwp", "memuAdatabase", "memuAcontrol", "memuAfiles", "memuAlogs", "memuAxterm", "memuAcrontab", "memuAsoft", "memuAconfig", "dologin", "memu_btwaf", "memuAssl"]' > /www/server/panel/config/show_menu.json \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /www/reserve_space.pl \
&& chmod +x /bt.sh \
&& chmod +x /init_mysql.sh
# 配置宝塔面板安全入口和用户名及密码,以及 SSH 密码
RUN echo btpanel | bt 6 \
&& echo btpaneldocker | bt 5 \
&& echo "/btpanel" > /www/server/panel/data/admin_path.pl \
&& echo "root:btpaneldocker" | chpasswd
# 打包宝塔面板并清除www
RUN tar -zcf /www.tar.gz /www \
&& rm -rf /www
ENTRYPOINT ["/bin/sh","-c","/bt.sh"]
# 暴漏所有端口
EXPOSE 0-65535
# 健康检查
HEALTHCHECK --interval=5s --timeout=3s CMD prot="http"; if [ -f "/www/server/panel/data/ssl.pl" ]; then prot="https"; fi; curl -k -i $prot://127.0.0.1:$(cat /www/server/panel/data/port.pl)$(cat /www/server/panel/data/admin_path.pl) | grep -E '(200|404)' || exit 1

View File

@ -1,97 +0,0 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
init_path=/etc/init.d
Root_Path=`cat /var/bt_setupPath.conf`
Setup_Path=$Root_Path/server/mysql
Data_Path=$Root_Path/server/data
O_pl=$(cat /www/server/panel/data/o.pl)
backup_database() {
if [ -d "${Data_Path}" ] && [ ! -z "$(ls -A ${Data_Path})" ]; then
if [ ! -d "${Setup_Path}" ] || [ -z "$(ls -A ${Setup_Path})" ]; then
timestamp=$(date +"%s")
tar czf /www/server/data_backup_$timestamp.tar.gz -C ${Data_Path} .
fi
fi
}
restore_panel_data() {
if [ -f /www.tar.gz ]; then
if [ ! -d /www ] || [ -z "$(ls -A /www)" ] || [ ! -d /www/server/panel ] || [ -z "$(ls -A /www/server/panel)" ] || [ ! -d /www/server/panel/pyenv ] || [ -z "$(ls -A /www/server/panel/pyenv)" ]; then
tar xzf /www.tar.gz -C / --skip-old-files
rm -rf /www.tar.gz
fi
fi
}
soft_start(){
# 扫描并启动所有服务
init_scripts=$(ls ${init_path})
for script in ${init_scripts}; do
case "${script}" in
"bt"|"mysqld"|"nginx"|"httpd")
continue
;;
esac
${init_path}/${script} start
done
if [ -f ${init_path}/nginx ]; then
${init_path}/nginx start
elif [ -f ${init_path}/httpd ]; then
${init_path}/httpd start
fi
${init_path}/bt stop
${init_path}/bt start
pkill crond
/sbin/crond
chmod 600 /etc/ssh/ssh_host_*
/usr/sbin/sshd -D &
}
init_mysql(){
if [ "${O_pl}" != "docker_btlamp_nas" ] && [ "${O_pl}" != "docker_btlnmp_nas" ];then
return
fi
if [ -d "${Data_Path}" ]; then
check_z=$(ls "${Data_Path}")
echo "check_z:"
echo ${check_z}
if [[ ! -z "${check_z}" ]]; then
echo "check_z is not empty"
return
fi
fi
if [ -f /init_mysql.sh ] && [ -d "${Setup_Path}" ];then
bash /init_mysql.sh
rm -f /init_mysql.sh
fi
}
is_empty_Data(){
return "$(ls -A ${Data_Path}/|wc -w)"
}
start_mysql(){
if [ -d "${Setup_Path}" ] && [ -f "${init_path}/mysqld" ];then
chown -R mysql:mysql ${Data_Path}
chgrp -R mysql ${Setup_Path}/.
${init_path}/mysqld start
fi
}
restore_panel_data > /dev/null
backup_database > /dev/null
is_empty_Data > /dev/null
init_mysql > /dev/null
start_mysql > /dev/null
soft_start > /dev/null
#tail -f /dev/null
${init_path}/bt log

View File

@ -1,41 +0,0 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
Root_Path=`cat /var/bt_setupPath.conf`
Setup_Path=$Root_Path/server/mysql
Data_Path=$Root_Path/server/data
Mysql_Initialize(){
if [ -d "${Data_Path}" ]; then
check_z=$(ls "${Data_Path}")
if [[ ! -z "${check_z}" ]]; then
return
fi
fi
mkdir -p ${Data_Path}
chown -R mysql:mysql ${Data_Path}
chgrp -R mysql ${Setup_Path}/.
${Setup_Path}/bin/mysqld --initialize-insecure --basedir=${Setup_Path} --datadir=${Data_Path} --user=mysql
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
${Setup_Path}/lib
EOF
ldconfig
ln -sf ${Setup_Path}/lib/mysql /usr/lib/mysql
ln -sf ${Setup_Path}/include/mysql /usr/include/mysql
/etc/init.d/mysqld start
mysqlpwd=`cat /dev/urandom | head -n 16 | md5sum | head -c 16`
${Setup_Path}/bin/mysqladmin -u root password "${mysqlpwd}"
cd "${Setup_Path}"
rm -f src.tar.gz
rm -rf src
/etc/init.d/mysqld start
rm -rf /init_mysql.sh
}
Mysql_Initialize