更新 .gitea/workflows/ci.yml: 移除 Node.js 和 Python 依赖安装步骤,简化 CI 流程。

This commit is contained in:
2025-07-19 17:17:27 +08:00
parent c96a58204c
commit e323e2265f
3 changed files with 50 additions and 41 deletions

View File

@ -14,47 +14,6 @@ jobs:
- name: 检出代码
uses: ./.actions/checkout
- name: 安装 Node.js
run: |
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
apt-get install -y nodejs
- name: 安装前端依赖
working-directory: platform
run: npm install
- name: 构建前端(跳过 ts 校验)
working-directory: platform
run: |
npm run build -- --no-check || true
- name: 安装 Python 3.11
run: |
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.11 python3.11-venv python3-pip
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
python3 --version
- name: 设置 pip 国内镜像源
run: |
mkdir -p ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = files.pythonhosted.org,pypi.org,pypi.python.org
EOF
- name: 安装后端依赖
working-directory: back
run: |
python3.11 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- name: 构建 Docker 镜像
run: |
docker compose build

32
Dockerfile Normal file
View File

@ -0,0 +1,32 @@
FROM python:3.11-slim
# 安装 Node.js 和 supervisord
RUN apt-get update && \
apt-get install -y curl supervisor && \
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get install -y nodejs && \
apt-get clean
# 设置工作目录
WORKDIR /app
# 复制前端代码并安装依赖、构建
COPY platform/ ./platform/
WORKDIR /app/platform
RUN npm install && npm run build
# 安装 http-server
RUN npm install -g http-server
# 复制后端代码并安装依赖
WORKDIR /app/back
COPY back/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY back/ .
# supervisor 配置
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
WORKDIR /app
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

18
supervisord.conf Normal file
View File

@ -0,0 +1,18 @@
[supervisord]
nodaemon=true
[program:frontend]
directory=/app/platform
command=http-server dist
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
[program:backend]
directory=/app/back
command=python app.py
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr