diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fa7144d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,28 @@ +.git +.env +.env.* +!.env.example + +__pycache__/ +*.py[cod] +*.pyo +.pytest_cache/ +.ruff_cache/ +.mypy_cache/ +.coverage + +backend/.venv/ +backend/storage/ +storage/ +reports/ +uploads/ +*.db +*.sqlite +*.sqlite3 +*.log +*.pdf + +frontend/ +docs/ +demo_frontend/ +scripts/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ae59838 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.11-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PIP_NO_CACHE_DIR=1 + +WORKDIR /app + +COPY backend/requirements.txt ./requirements.txt + +RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple \ + --no-cache-dir \ + -r requirements.txt + +COPY backend ./backend + +WORKDIR /app/backend + +EXPOSE 9000 + +CMD [ + "uvicorn", + "app.main:app", + "--host", + "0.0.0.0", + "--port", + "9000" +] diff --git a/README.md b/README.md index 8b876c4..53c1132 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,13 @@ cd backend uvicorn app.main:app --host 127.0.0.1 --port 9000 ``` +Docker 构建与运行: + +```powershell +docker build -t medical-consultation-agent-backend . +docker run --env-file .env -p 9000:9000 medical-consultation-agent-backend +``` + ## 服务依赖 MySQL 使用容器或内网服务名 `mysql`: diff --git a/backend/requirements.txt b/backend/requirements.txt index 7435c1b..773ecba 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -7,5 +7,4 @@ aiomysql>=0.2.0 httpx>=0.27.0 python-dotenv>=1.0.0 reportlab>=4.2.0 -streamlit>=1.36.0 redis>=5.0.0