mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
ci: speed up Docker build checks (#1820)
* ci: speed up docker build checks * test: align Dockerfile cache assertion
This commit is contained in:
@@ -3,11 +3,19 @@ __pycache__/
|
|||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
*.so
|
*.so
|
||||||
|
.pytest_cache/
|
||||||
|
.mypy_cache/
|
||||||
|
.ruff_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
|
||||||
# 忽略虚拟环境
|
# 忽略虚拟环境
|
||||||
venv/
|
venv/
|
||||||
.venv/
|
.venv/
|
||||||
env/
|
env/
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
.env.local
|
.env.local
|
||||||
|
|
||||||
# 忽略 IDE
|
# 忽略 IDE
|
||||||
@@ -16,15 +24,30 @@ env/
|
|||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
# 忽略数据文件(可选,如果想持久化就注释掉)
|
# 忽略本地仓库、CI 元数据和运行产物
|
||||||
# data/
|
.git/
|
||||||
# logs/
|
.github/
|
||||||
# reports/
|
.claude/reviews/
|
||||||
|
data/
|
||||||
|
logs/
|
||||||
|
reports/
|
||||||
|
*.log
|
||||||
|
|
||||||
# 忽略测试文件
|
# 忽略测试和文档
|
||||||
|
tests/
|
||||||
test_*.py
|
test_*.py
|
||||||
*_test.py
|
*_test.py
|
||||||
|
docs/
|
||||||
# 忽略文档
|
|
||||||
*.md
|
*.md
|
||||||
!README.md
|
!README.md
|
||||||
|
|
||||||
|
# 忽略不参与 Docker 镜像构建的前端/桌面端产物
|
||||||
|
apps/dsa-desktop/
|
||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
coverage/
|
||||||
|
apps/dsa-web/node_modules/
|
||||||
|
apps/dsa-web/dist/
|
||||||
|
apps/dsa-web/build/
|
||||||
|
apps/dsa-web/coverage/
|
||||||
|
|||||||
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
@@ -79,14 +79,23 @@ jobs:
|
|||||||
docker-build:
|
docker-build:
|
||||||
name: docker-build
|
name: docker-build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [backend-gate]
|
needs: [ai-governance]
|
||||||
steps:
|
steps:
|
||||||
- name: 📥 Checkout
|
- name: 📥 Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
|
- name: 🛠️ Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: 🐳 Build image
|
- name: 🐳 Build image
|
||||||
run: |
|
uses: docker/build-push-action@v6
|
||||||
docker build -t stock-analysis:test -f docker/Dockerfile .
|
with:
|
||||||
docker run --rm stock-analysis:test python -c "print('✅ Docker OK')"
|
context: .
|
||||||
|
file: docker/Dockerfile
|
||||||
|
tags: stock-analysis:test
|
||||||
|
load: true
|
||||||
|
cache-from: type=gha,scope=stock-analysis-ci-docker
|
||||||
|
cache-to: type=gha,mode=max,scope=stock-analysis-ci-docker,ignore-error=true
|
||||||
|
- name: 🐳 Docker smoke
|
||||||
|
run: docker run --rm stock-analysis:test python -c "print('✅ Docker OK')"
|
||||||
- name: 🔍 Docker smoke imports
|
- name: 🔍 Docker smoke imports
|
||||||
run: |
|
run: |
|
||||||
docker run --rm stock-analysis:test python -c "
|
docker run --rm stock-analysis:test python -c "
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
# ===================================
|
# ===================================
|
||||||
# A股自选股智能分析系统 - Docker 镜像
|
# A股自选股智能分析系统 - Docker 镜像
|
||||||
# ===================================
|
# ===================================
|
||||||
@@ -8,7 +10,7 @@ FROM node:20-slim AS web-builder
|
|||||||
WORKDIR /app/apps/dsa-web
|
WORKDIR /app/apps/dsa-web
|
||||||
|
|
||||||
COPY apps/dsa-web/package.json apps/dsa-web/package-lock.json ./
|
COPY apps/dsa-web/package.json apps/dsa-web/package-lock.json ./
|
||||||
RUN npm ci
|
RUN --mount=type=cache,target=/root/.npm npm ci
|
||||||
|
|
||||||
COPY apps/dsa-web/ ./
|
COPY apps/dsa-web/ ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
@@ -44,7 +46,7 @@ RUN groupadd -g 1000 dsa && \
|
|||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
# 安装 Python 依赖
|
# 安装 Python 依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
|
||||||
|
|
||||||
# 复制应用代码
|
# 复制应用代码
|
||||||
COPY *.py ./
|
COPY *.py ./
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ def test_dockerfile_bundles_default_alphasift_adapter() -> None:
|
|||||||
|
|
||||||
assert "git \\" in dockerfile
|
assert "git \\" in dockerfile
|
||||||
assert "git+https://github.com/ZhuLinsen/alphasift.git@377049857cc04175dc3cca62121ee41adec6cdb8#egg=alphasift" in requirements
|
assert "git+https://github.com/ZhuLinsen/alphasift.git@377049857cc04175dc3cca62121ee41adec6cdb8#egg=alphasift" in requirements
|
||||||
assert "pip install --no-cache-dir -r requirements.txt" in dockerfile
|
assert "pip install -r requirements.txt" in dockerfile
|
||||||
|
assert "--mount=type=cache,target=/root/.cache/pip" in dockerfile
|
||||||
assert "import alphasift.dsa_adapter" in dockerfile
|
assert "import alphasift.dsa_adapter" in dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user