element-hq / element-hq/synapse
Use `uv` to install dependencies in the Dockerfile
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
*See [parent issue](https://github.com/element-hq/synapse/issues/19566) for more context*
### Current state
**`docker/Dockerfile` (main image)** — already partially migrated:
- Stage 0 (`requirements`): Uses `uvx` to run `poetry export` to generate `requirements.txt` from `poetry.lock`. Copies `pyproject.toml` and `poetry.lock`.
- Stage 1 (`builder`): Uses `uv pip install` to install from the exported `requirements.txt`. No Poetry at all.
- Stage 3 (`runtime`): Excludes `.lock` file from the final image.
This can be switched to use `uv.lock` directly via `uv export` (which replaces `poetry export`) or `uv sync`/`uv pip install` from the lockfile, removing the Poetry dependency entirely from the Docker build.
**`docker/editable.Dockerfile`** (used by Complement tests) — still fully Poetry-based:
- `pip install poetry`
- `poetry config virtualenvs.create false`
- `poetry install --extras all`
- Copies `poetry.lock` for change detection (compared via `diff` in `complement.sh`)
### Changes needed
**`docker/Dockerfile`:**
- Replace `poetry export` with `uv export --no-emit-project --frozen` (or equivalent) to generate `requirements.txt` from `uv.lock`
- Remove the `POETRY_VERSION` build arg
- Copy `uv.lock` instead of `poetry.lock`
- Keep the `TEST_ONLY_IGNORE_POETRY_LOCKFILE` / `TEST_ONLY_SKIP_DEP_HASH_VERIFICATION` args (rename to remove "POETRY" reference) for CI flexibility
**`docker/editable.Dockerfile`:**
- Replace `pip install poetry` + `poetry install` with `uv sync` or `uv pip install -e`
- Copy `uv.lock` instead of `poetry.lock`
- Update the lockfile backup for change detection
**`scripts-dev/complement.sh`:**
- Line 201: Change `poetry.lock` diff check to `uv.lock`
- Line 237: Replace `poetry run python -c '...'` with `uv run python -c '...'`
- Line 245: Rename `TEST_ONLY_IGNORE_POETRY_LOCKFILE` build arg
Contributor guide
Assessment
This issue has not been assessed yet.