Skip to content

Commit

Permalink
0.9.8.3
Browse files Browse the repository at this point in the history
#####
1. 更新安装脚本
2. 更新Docker部署
3. 更新文本
4. 更新Dockerfile
5. 优化配置文件路径结构

#####
  • Loading branch information
Xingsandesu committed Jan 19, 2024
1 parent 36d4e53 commit 5694eed
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 39 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: build_docker

on:
release:
types: [created] # 表示在创建新的 Release 时触发

jobs:
build_docker:
name: Build docker
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/taichios:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/taichios:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@ cython_debug/
/app.py
/get-docker.sh
/config.json
/work/
2 changes: 1 addition & 1 deletion .shell/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tar -zvxf Python-3.11.7.tgz
echo "编译安装Python"
cd Python-3.11.7
echo "Python源码lto优化"
./configure --enable-optimizations
./configure --enable-optimizations --prefix=/usr/taichi/python
echo "Python源码编译"
make
echo "Python源码编译"
Expand Down
179 changes: 165 additions & 14 deletions .shell/get-taichi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ EOF
echo "太极OS安装完成,您可以通过以下地址访问:${ip}:${port}"
}

docker_install_taichi() {
python_install_taichi() {
# 安装操作
echo "开始安装..."
# 检查Docker是否已安装
Expand All @@ -765,12 +765,137 @@ docker_install_taichi() {
}
EOF
echo "Docker配置覆盖完成"
echo "系统更新并安装依赖"
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$ID
else
echo "Cannot identify the OS"
exit 1
fi

if [ "$OS" = "ubuntu" ] || [ "$OS" = "debian" ]; then
sudo apt -y update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git unzip
elif [ "$OS" = "centos" ]; then
sudo yum update -y
sudo yum groupinstall -y "Development Tools"
sudo yum install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils unzip
elif [ "$OS" = "fedora" ]; then
sudo dnf upgrade -y
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils unzip
elif [ "$OS" = "opensuse-leap" ]; then
sudo zypper refresh
sudo zypper install -y make gcc libssl-devel zlib-devel libbz2-devel \
readline-devel sqlite3-devel wget curl llvm ncurses-devel ncurses5-devel \
xz-utils tk-devel libffi-devel liblzma5 python-openssl git unzip
elif [ "$OS" = "arch" ]; then
sudo pacman -Syu --needed --noconfirm make gcc openssl zlib bzip2 \
readline sqlite wget curl llvm ncurses xz tk libffi xz python openssl git unzip
else
echo "Unsupported OS"
exit 1
fi


mkdir -p /usr/taichi
echo "目录创建完成"
wget -P /usr/taichi https://download.kookoo.top/TAICHI_OS
chmod 755 /usr/taichi/TAICHI_OS
echo "文件下载完成"
wget -P /usr/taichi https://codeload.github.com/Xingsandesu/TaiChi_OS/zip/refs/heads/master
unzip /usr/taichi/master -d /usr/taichi
echo "文件下载并解压完成"
echo "解压Python源码"
tar -zvxf /usr/taichi/.shell/Python-3.11.7.tgz
echo "编译安装Python"
cd /usr/taichi/.shell/Python-3.11.7
echo "Python源码lto优化"
./configure --enable-optimizations --prefix=/usr/taichi/python
echo "Python源码编译"
make
echo "Python源码编译"
make install
echo "安装软件依赖, 更换国内源"
cd /usr/taichi
/usr/taichi/python/bin/pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pip -U
/usr/taichi/python/bin/pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
/usr/taichi/python/bin/pip3 install -r requirements.txt



# 写入service
echo "请输入程序运行的端口:"
read port
cat << EOF > /etc/systemd/system/taichi.service
[Unit]
Description=Taichi
Documentation=https://app.kookoo.top
After=network.target
Wants=network.target
[Service]
WorkingDirectory=/usr/taichi
ExecStart=/usr/taichi/python/bin/python3 /usr/taichi/run.py --port=${port}
Restart=on-abnormal
RestartSec=5s
KillMode=mixed
StandardOutput=null
StandardError=syslog
[Install]
WantedBy=multi-user.target
EOF
echo "服务写入完成"

# 更新配置
systemctl daemon-reload
echo "配置更新完成"

# 启动服务
systemctl start taichi
echo "服务启动完成"

# 设置开机启动
systemctl enable taichi
echo "设置开机启动完成"

# 获取用户的IP地址
ip=$(hostname -I | awk '{print $1}')

echo "太极OS安装完成,您可以通过以下地址访问:${ip}:${port}"
}


docker_install_taichi() {
# 安装操作
echo "开始安装..."
# 检查Docker是否已安装
if ! command -v docker &> /dev/null
then
echo "Docker 没有安装, 将自动安装"
do_install
else
echo "Docker 已经安装."
fi

# 覆盖/etc/docker/daemon.json
if [ ! -d "/etc/docker" ]; then
mkdir -p /etc/docker
fi

cat << EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
"https://mirror.ccs.tencentyun.com"
]
}
EOF
echo "Docker配置覆盖完成"

mkdir -p /usr/taichi/work
echo "目录创建完成"

# 询问用户输入端口
echo "请输入程序运行的端口:"
Expand All @@ -780,6 +905,7 @@ EOF
-p ${host_port}:80 \
-v /usr/taichi:/taichi_os \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/taichi/work:/taichi_os/work \
--name taichios \
--restart=always \
fushin/taichios
Expand Down Expand Up @@ -811,29 +937,39 @@ update_taichi() {
else
# Docker版本
docker stop taichi
rm -rf /usr/taichi/TAICHI_OS
wget -P /usr/taichi https://download.kookoo.top/TAICHI_OS
chmod 755 /usr/taichi/TAICHI_OS
docker rm taichi
docker pull kookoo/taichi:latest
docker restart taichi
docker_install_taichi
fi
}

python_update_taichi() {
systemctl stop taichi
mv /usr/taichi/python /tmp/taichi/python
rm -rf /usr/taichi/*
mv /tmp/taichi/python /usr/taichi/python
wget -P /usr/taichi https://codeload.github.com/Xingsandesu/TaiChi_OS/zip/refs/heads/master
unzip /usr/taichi/master -d /usr/taichi
systemctl start taichi
systemctl daemon-reload
}

echo "=========太极OS========="
echo "WIKI:https://github.com/Xingsandesu/TaiChi_OS"
echo "官方软件源:https://app.kookoo.top"
echo "=========太极OS========="
echo "请选择操作:"
echo "1. 安装"
echo "1. 二进制安装(AMD64)"
echo "2. 卸载"
echo "3. 更新"
echo "4. 重启"
echo "5. 恢复默认设置"
echo "6. 重置账号密码"
echo "7. 更换端口"
echo "8. 更换软件源"
echo "9. 使用Docker安装(不推荐,如果遇到没有对应glibc库,使用Docker安装,文件管理需要自己指定映射目录)"
echo "9. 使用Docker安装(AMD64, ARM64 如果遇到没有对应glibc库,使用Docker安装,文件管理需要自己指定映射目录)"
echo "10. 源码安装(适用于所有架构)"
echo "11. 源码更新"
echo "=========太极OS========="
read operation

Expand All @@ -858,19 +994,24 @@ case $operation in
4)
# 重启操作
echo "开始重启..."
systemctl restart taichi
if systemctl --all --type=service | grep -q 'taichi'; then
systemctl restart taichi

else
docker restart taichi
fi
echo "重启完毕"
;;
5)
# 恢复默认设置
echo "开始恢复默认设置..."
rm /usr/taichi/config.json
rm /usr/taichi/work/config.json
echo "恢复默认设置完毕"
;;
6)
# 重置账号密码
echo "开始重置账号密码..."
rm /usr/taichi/data.db
rm /usr/taichi/work/data.db
echo "重置账号密码完毕"
;;
7)
Expand All @@ -889,13 +1030,23 @@ case $operation in
if [[ $new_source != http://* ]]; then
new_source="http://${new_source}"
fi
sed -i "s|\"source_url\": \".*\"|\"source_url\": \"${new_source}\"|g" /usr/taichi/config.json
sed -i "s|\"source_url\": \".*\"|\"source_url\": \"${new_source}\"|g" /usr/taichi/work/config.json
;;
9)
echo "Docker安装开始"
docker_install_taichi
echo "Docker安装完毕"
;;
10)
echo "源码安装开始"
python_install_taichi
echo "源码安装完毕"
;;
11)
echo "源码更新开始"
python_update_taichi
echo "源码更新完毕"
;;
*)
echo "无效的操作"
;;
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11.7-slim-bookworm
LABEL authors="huxin"

# 安装依赖
RUN apt-get update && \
apt-get install -y ca-certificates && mkdir -p /taichi_os/work

WORKDIR /taichi_os

# 复制应用
COPY . /taichi_os

# 安装依赖
RUN pip install -r requirements.txt

EXPOSE 80
# 入口命令
CMD ["python", "run.py"]
Loading

0 comments on commit 5694eed

Please sign in to comment.