db867dcbe5
Deploy to Staging / deploy (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Lint Backend / lint-backend (push) Has been cancelled
Playwright Tests / changes (push) Has been cancelled
Test Backend / test-backend (push) Has been cancelled
Test Docker Compose / test-docker-compose (push) Has been cancelled
Playwright Tests / test-playwright (1, 4) (push) Has been cancelled
Playwright Tests / test-playwright (2, 4) (push) Has been cancelled
Playwright Tests / test-playwright (3, 4) (push) Has been cancelled
Playwright Tests / test-playwright (4, 4) (push) Has been cancelled
Playwright Tests / merge-playwright-reports (push) Has been cancelled
Playwright Tests / alls-green-playwright (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
45 lines
1.2 KiB
Docker
45 lines
1.2 KiB
Docker
FROM python:3.10
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
WORKDIR /app/
|
|
|
|
# 安装 uv
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
|
|
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
|
|
|
|
# 将可执行文件放在环境路径的最前面
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
|
|
# 编译字节码
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
|
|
ENV UV_COMPILE_BYTECODE=1
|
|
|
|
# uv 缓存
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#caching
|
|
ENV UV_LINK_MODE=copy
|
|
|
|
# 安装依赖
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
--mount=type=bind,source=uv.lock,target=uv.lock \
|
|
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
|
uv sync --frozen --no-install-project
|
|
|
|
ENV PYTHONPATH=/app
|
|
|
|
COPY ./scripts /app/scripts
|
|
|
|
COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
|
|
|
|
COPY ./app /app/app
|
|
COPY ./tests /app/tests
|
|
|
|
# 同步项目
|
|
# 参考: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
uv sync
|
|
|
|
CMD ["fastapi", "run", "--workers", "4", "app/main.py"]
|