From 44a8d66e865724ee6ec2910ffd6a92d66600347c Mon Sep 17 00:00:00 2001 From: liaotxcn Date: Thu, 26 Mar 2026 14:14:43 +0800 Subject: [PATCH 1/4] cicd: Add workflow and Docker deployment configuration --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ Dockerfile | 24 ++++++++++++++++++++++++ docker-compose.yml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..baa4e56 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest mypy + + - name: Type check with mypy + run: | + mypy app/ + + - name: Test with pytest + run: | + pytest -v + + - name: Check build + run: | + python -m pip install build + python -m build --sdist --wheel --no-isolation \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5614807 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.11-slim + +# 设置工作目录 +WORKDIR /app + +# 安装系统依赖 +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +# 复制 requirements.txt 文件 +COPY requirements.txt . + +# 安装 Python 依赖 +RUN pip install --no-cache-dir -r requirements.txt + +# 复制项目文件 +COPY . . + +# 暴露端口 +EXPOSE 8000 + +# 启动命令 +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8c7df25 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3.8' + +services: + fastagent: + build: . + ports: + - "8000:8000" + volumes: + - .:/app + environment: + - MODELscope_api_key=${MODELscope_api_key} + - MODELscope_api_base=${MODELscope_api_base} + - MODELscope_model_id=${MODELscope_model_id} + - DATABASE_URL=${DATABASE_URL} + - MCP_server_url=${MCP_server_url} + - LOG_level=${LOG_level} + depends_on: + - db + restart: unless-stopped + + db: + image: mysql:8.0 + ports: + - "3306:3306" + environment: + - MYSQL_ROOT_PASSWORD=123456 + - MYSQL_DATABASE=fastagent + - MYSQL_USER=fastagent + - MYSQL_PASSWORD=123456 + volumes: + - mysql_data:/var/lib/mysql + restart: unless-stopped + +volumes: + mysql_data: \ No newline at end of file From 4798957608d9d441bec77bb2df8e45081d315524 Mon Sep 17 00:00:00 2001 From: liaotxcn Date: Thu, 26 Mar 2026 14:37:03 +0800 Subject: [PATCH 2/4] cicd: update workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baa4e56..baef6b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - name: Type check with mypy run: | - mypy app/ + mypy --explicit-package-bases app/ - name: Test with pytest run: | From 6130123a520fe5ebbf91a937a010d431ab7b4cc0 Mon Sep 17 00:00:00 2001 From: liaotxcn Date: Thu, 26 Mar 2026 15:04:14 +0800 Subject: [PATCH 3/4] cicd: update workflow --- .github/workflows/ci.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baef6b6..0113cfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,16 +21,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install pytest mypy - - - name: Type check with mypy - run: | - mypy --explicit-package-bases app/ - - - name: Test with pytest - run: | - pytest -v - + - name: Check build run: | python -m pip install build From b8424252ace9a83b6c2d1e8ccbc141c5c56f5a8c Mon Sep 17 00:00:00 2001 From: liaotxcn Date: Thu, 26 Mar 2026 15:25:06 +0800 Subject: [PATCH 4/4] cicd: update workflow --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0113cfa..ca2e0d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - - - name: Check build + + - name: Compile check run: | - python -m pip install build - python -m build --sdist --wheel --no-isolation \ No newline at end of file + python -m py_compile app/**/*.py