fix(ci): test backend in container environment
This commit is contained in:
@@ -13,11 +13,7 @@ jobs:
|
|||||||
image_name: gitea.waternetwork.cn/orgtjwater/tjwater-backend
|
image_name: gitea.waternetwork.cn/orgtjwater/tjwater-backend
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
build_context: .
|
build_context: .
|
||||||
test_command: |
|
test_target: test
|
||||||
python -m compileall -q app
|
|
||||||
python -c "import app.main"
|
|
||||||
python scripts/check_openapi.py
|
|
||||||
pytest -q tests
|
|
||||||
deploy_service: backend
|
deploy_service: backend
|
||||||
deploy_host: 192.168.1.114
|
deploy_host: 192.168.1.114
|
||||||
secrets:
|
secrets:
|
||||||
|
|||||||
+11
-3
@@ -1,4 +1,4 @@
|
|||||||
FROM condaforge/miniforge3:latest
|
FROM condaforge/miniforge3:latest AS base
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -20,8 +20,6 @@ COPY app ./app
|
|||||||
COPY contracts ./contracts
|
COPY contracts ./contracts
|
||||||
COPY infra ./infra
|
COPY infra ./infra
|
||||||
COPY resources ./resources
|
COPY resources ./resources
|
||||||
COPY scripts/check_openapi.py ./scripts/check_openapi.py
|
|
||||||
COPY tests ./tests
|
|
||||||
RUN python -c "from pathlib import Path; from zipfile import ZipFile; model_dir = Path('app/algorithms/pipe_health_prediction/model'); zip_path = model_dir / 'my_survival_forest_model_quxi.zip'; joblib_name = 'my_survival_forest_model_quxi.joblib'; joblib_path = model_dir / joblib_name; assert zip_path.exists(), f'Model archive not found: {zip_path}'; archive = ZipFile(zip_path); archive.extract(joblib_name, model_dir); archive.close(); assert joblib_path.exists(), f'Model file not extracted: {joblib_path}'" && \
|
RUN python -c "from pathlib import Path; from zipfile import ZipFile; model_dir = Path('app/algorithms/pipe_health_prediction/model'); zip_path = model_dir / 'my_survival_forest_model_quxi.zip'; joblib_name = 'my_survival_forest_model_quxi.joblib'; joblib_path = model_dir / joblib_name; assert zip_path.exists(), f'Model archive not found: {zip_path}'; archive = ZipFile(zip_path); archive.extract(joblib_name, model_dir); archive.close(); assert joblib_path.exists(), f'Model file not extracted: {joblib_path}'" && \
|
||||||
rm -f app/algorithms/pipe_health_prediction/model/my_survival_forest_model_quxi.zip
|
rm -f app/algorithms/pipe_health_prediction/model/my_survival_forest_model_quxi.zip
|
||||||
RUN mkdir -p db_inp temp data inp
|
RUN mkdir -p db_inp temp data inp
|
||||||
@@ -29,6 +27,16 @@ RUN mkdir -p db_inp temp data inp
|
|||||||
# 设置 PYTHONPATH 以便 uvicorn 找到 app 模块
|
# 设置 PYTHONPATH 以便 uvicorn 找到 app 模块
|
||||||
ENV PYTHONPATH=/app
|
ENV PYTHONPATH=/app
|
||||||
|
|
||||||
|
FROM base AS test
|
||||||
|
COPY scripts ./scripts
|
||||||
|
COPY tests ./tests
|
||||||
|
RUN python -m compileall -q app && \
|
||||||
|
python -c "import app.main" && \
|
||||||
|
python scripts/check_openapi.py && \
|
||||||
|
pytest -q tests
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]
|
||||||
|
|||||||
Reference in New Issue
Block a user