Skip to content

Commit

Permalink
Merge branch 'develop' into update-server-notice-user-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
watson28 committed Apr 7, 2022
2 parents 48cab46 + 7732c49 commit bd7303d
Show file tree
Hide file tree
Showing 287 changed files with 11,812 additions and 7,073 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
# things to include
!docker
!synapse
!MANIFEST.in
!README.rst
!pyproject.toml
!poetry.lock

# TODO: remove these once we have moved over to using poetry-core in pyproject.toml
!MANIFEST.in
!setup.py

**/__pycache__
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup mdbook
uses: peaceiris/actions-mdbook@4b5ef36b314c2599664ca107bb8c02412548d79d # v1.1.14
with:
mdbook-version: '0.4.9'
mdbook-version: '0.4.17'

- name: Build the documentation
# mdbook will only create an index.html if we're including docs/README.md in SUMMARY.md.
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
- "check_codestyle"
- "check_isort"
- "mypy"
- "packaging"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -377,7 +376,7 @@ jobs:
# Run Complement
- run: |
set -o pipefail
go test -v -json -p 1 -tags synapse_blacklist,msc2403,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
go test -v -json -tags synapse_blacklist,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
shell: bash
name: Run Complement Tests
env:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ _trial_temp*/
.DS_Store
__pycache__/

# We do want the poetry lockfile. TODO: is there a good reason for ignoring
# '*.lock' above? If not, let's nuke it.
!poetry.lock

# stuff that is likely to exist when you run a server locally
/*.db
/*.log
Expand All @@ -30,6 +34,9 @@ __pycache__/
/media_store/
/uploads

# For direnv users
/.envrc

# IDEs
/.idea/
/.ropeproject/
Expand Down
3,640 changes: 3,640 additions & 0 deletions CHANGES-pre-1.0.md

Large diffs are not rendered by default.

3,764 changes: 121 additions & 3,643 deletions CHANGES.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions changelog.d/11881.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Send device list changes to application services as specified by [MSC3202](https://github.com/matrix-org/matrix-spec-proposals/pull/3202), using unstable prefixes. The `msc3202_transaction_extensions` experimental homeserver config option must be enabled and `org.matrix.msc3202: true` must be present in the application service registration file for device list changes to be sent. The "left" field is currently always empty.
1 change: 1 addition & 0 deletions changelog.d/12040.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optimise fetching large quantities of missing room state over federation.
1 change: 1 addition & 0 deletions changelog.d/12165.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove lingering unstable references to MSC2403 (knocking).
1 change: 1 addition & 0 deletions changelog.d/12191.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12193.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Omit sending "offline" presence updates to application services after they are initially configured.
1 change: 0 additions & 1 deletion changelog.d/12198.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12199.misc

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/12209.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to using a sequence to generate AS transaction IDs. Contributed by Nick Beeper. If running synapse with a dedicated appservice worker, this MUST be stopped before upgrading the main process and database.
1 change: 0 additions & 1 deletion changelog.d/12216.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12219.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12224.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12225.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12227.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12231.doc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12232.misc

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/12242.misc

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/12251.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Offload the `update_client_ip` background job from the main process to the background worker, when using Redis-based replication.
1 change: 1 addition & 0 deletions changelog.d/12267.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing type hints for storage.
1 change: 1 addition & 0 deletions changelog.d/12271.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify documentation for running SyTest against Synapse, including use of Postgres and worker mode.
1 change: 1 addition & 0 deletions changelog.d/12293.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the unused and unstable `/aggregations` endpoint which was removed from [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).
1 change: 1 addition & 0 deletions changelog.d/12295.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654) support behind an experimental configuration flag.
1 change: 1 addition & 0 deletions changelog.d/12302.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a module callback to react to new 3PID (email address, phone number) associations.
1 change: 1 addition & 0 deletions changelog.d/12310.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a configuration option to remove a specific set of rooms from sync responses.
1 change: 1 addition & 0 deletions changelog.d/12315.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document the behaviour of `LoggingTransaction.call_after` and `LoggingTransaction.call_on_exception` methods when transactions are retried.
1 change: 1 addition & 0 deletions changelog.d/12316.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12317.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update docstrings to explain how to decipher live and historic pagination tokens.
1 change: 1 addition & 0 deletions changelog.d/12321.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ground work for speeding up device list updates for users in large numbers of rooms.
1 change: 1 addition & 0 deletions changelog.d/12326.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix typechecker problems exposed by signedjson 1.1.2.
1 change: 1 addition & 0 deletions changelog.d/12327.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a module callback to react to account data changes.
1 change: 1 addition & 0 deletions changelog.d/12329.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix non-member state events not resolving for historical events when used in [MSC2716](https://github.com/matrix-org/matrix-spec-proposals/pull/2716) `/batch_send` `state_events_at_start`.
1 change: 1 addition & 0 deletions changelog.d/12330.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12331.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update dead links in `check-newsfragment.sh` to point to the correct documentation URL.
1 change: 1 addition & 0 deletions changelog.d/12332.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12333.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug affecting URL previews that would generate a 500 response instead of a 403 if the previewed URL includes a port that isn't allowed by the relevant blacklist.
1 change: 1 addition & 0 deletions changelog.d/12334.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the `tox` packaging job: it will be redundant once #11537 lands.
1 change: 1 addition & 0 deletions changelog.d/12335.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore `.envrc` for `direnv` users.
1 change: 1 addition & 0 deletions changelog.d/12336.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the (broadly unused, dev-only) dockerfile for pg tests.
1 change: 1 addition & 0 deletions changelog.d/12338.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor relations code to remove an unnecessary class.
1 change: 1 addition & 0 deletions changelog.d/12339.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade the version of `mdbook` in CI to 0.4.17.
1 change: 1 addition & 0 deletions changelog.d/12341.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow setting user admin status using the module API. Contributed by Famedly.
1 change: 1 addition & 0 deletions changelog.d/12345.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updates to the Room DAG concepts development document to clarify that we mark events as outliers because we don't have any state for them.
1 change: 1 addition & 0 deletions changelog.d/12346.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove redundant `get_success` calls in test code.
1 change: 1 addition & 0 deletions changelog.d/12347.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add type annotations for `tests/unittest.py`.
1 change: 1 addition & 0 deletions changelog.d/12348.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move single-use methods out of `TestCase`.
1 change: 1 addition & 0 deletions changelog.d/12349.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions changelog.d/12350.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Default to `private` room visibility rather than `public` when a client does not specify one, according to spec.
1 change: 1 addition & 0 deletions changelog.d/12351.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions changelog.d/12353.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert `Linearizer` tests from `inlineCallbacks` to async.
1 change: 1 addition & 0 deletions changelog.d/12354.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update docstrings for `ReadWriteLock` tests.
1 change: 1 addition & 0 deletions changelog.d/12355.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions changelog.d/12357.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor `Linearizer`, convert methods to async and use an async context manager.
1 change: 1 addition & 0 deletions changelog.d/12358.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug where `Linearizer`s could get stuck if a cancellation were to happen at the wrong time.
1 change: 1 addition & 0 deletions changelog.d/12364.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a spec compliance issue where requests to the `/publicRooms` federation API would specify `limit` as a string.
1 change: 1 addition & 0 deletions changelog.d/12366.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make `StreamToken.from_string` and `RoomStreamToken.parse` propagate cancellations instead of replacing them with `SynapseError`s.
1 change: 1 addition & 0 deletions changelog.d/12367.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce overhead of restarting synchrotrons.
1 change: 1 addition & 0 deletions changelog.d/12369.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the link to Redis pub/sub documentation in the workers documentation..
1 change: 1 addition & 0 deletions changelog.d/12370.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update `/messages` to use historic pagination tokens if no `from` query parameter is given.
File renamed without changes.
1 change: 1 addition & 0 deletions changelog.d/12372.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce overhead of restarting synchrotrons.
1 change: 1 addition & 0 deletions changelog.d/12376.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow specifying the Postgres database's port when running unit tests with Postgres.
1 change: 1 addition & 0 deletions changelog.d/12379.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove temporary pin of signedjson<=1.1.1 that was added in Synapse 1.56.0.
1 change: 1 addition & 0 deletions changelog.d/12380.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add opentracing spans to calls to external cache.
1 change: 1 addition & 0 deletions changelog.d/12381.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lay groundwork for using `poetry` to manage Synapse's dependencies.
1 change: 1 addition & 0 deletions changelog.d/12384.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make missing `importlib_metadata` dependency explicit.
1 change: 1 addition & 0 deletions changelog.d/12385.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bundle locked versions of dependencies into the Docker image.
1 change: 1 addition & 0 deletions changelog.d/12389.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update type annotations for compatiblity with prometheus_client 0.14.
1 change: 1 addition & 0 deletions changelog.d/12390.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.49.0 which caused the `synapse_event_persisted_position` metric to have invalid values.
1 change: 1 addition & 0 deletions changelog.d/12392.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove documentation for converting a legacy structured logging configuration to the new format.
1 change: 1 addition & 0 deletions changelog.d/12398.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove support for the unstable identifiers specified in [MSC3288](https://github.com/matrix-org/matrix-doc/pull/3288).
1 change: 1 addition & 0 deletions changelog.d/12400.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make missing `importlib_metadata` dependency explicit.
1 change: 1 addition & 0 deletions changelog.d/12403.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support the stable `v1` endpoint for `/relations`, per [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).
1 change: 1 addition & 0 deletions changelog.d/12408.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not include groups in the sync response when disabled.
1 change: 1 addition & 0 deletions changelog.d/12409.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12410.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a spec compliance issue where requests to the `/publicRooms` federation API would specify `limit` as a string.
15 changes: 9 additions & 6 deletions contrib/jitsimeetbridge/jitsimeetbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,15 @@ def advertiseSsrcs(self):
time.sleep(7)
print("SSRC spammer started")
while self.running:
ssrcMsg = "<presence to='%(tojid)s' xmlns='jabber:client'><x xmlns='http://jabber.org/protocol/muc'/><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jitsi.org/jitsimeet' ver='0WkSdhFnAUxrz4ImQQLdB80GFlE='/><nick xmlns='http://jabber.org/protocol/nick'>%(nick)s</nick><stats xmlns='http://jitsi.org/jitmeet/stats'><stat name='bitrate_download' value='175'/><stat name='bitrate_upload' value='176'/><stat name='packetLoss_total' value='0'/><stat name='packetLoss_download' value='0'/><stat name='packetLoss_upload' value='0'/></stats><media xmlns='http://estos.de/ns/mjs'><source type='audio' ssrc='%(assrc)s' direction='sendre'/><source type='video' ssrc='%(vssrc)s' direction='sendre'/></media></presence>" % {
"tojid": "%s@%s/%s" % (ROOMNAME, ROOMDOMAIN, self.shortJid),
"nick": self.userId,
"assrc": self.ssrcs["audio"],
"vssrc": self.ssrcs["video"],
}
ssrcMsg = (
"<presence to='%(tojid)s' xmlns='jabber:client'><x xmlns='http://jabber.org/protocol/muc'/><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://jitsi.org/jitsimeet' ver='0WkSdhFnAUxrz4ImQQLdB80GFlE='/><nick xmlns='http://jabber.org/protocol/nick'>%(nick)s</nick><stats xmlns='http://jitsi.org/jitmeet/stats'><stat name='bitrate_download' value='175'/><stat name='bitrate_upload' value='176'/><stat name='packetLoss_total' value='0'/><stat name='packetLoss_download' value='0'/><stat name='packetLoss_upload' value='0'/></stats><media xmlns='http://estos.de/ns/mjs'><source type='audio' ssrc='%(assrc)s' direction='sendre'/><source type='video' ssrc='%(vssrc)s' direction='sendre'/></media></presence>"
% {
"tojid": "%s@%s/%s" % (ROOMNAME, ROOMDOMAIN, self.shortJid),
"nick": self.userId,
"assrc": self.ssrcs["audio"],
"vssrc": self.ssrcs["video"],
}
)
res = self.sendIq(ssrcMsg)
print("reply from ssrc announce: ", res)
time.sleep(10)
Expand Down
30 changes: 30 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
matrix-synapse-py3 (1.56.0) stable; urgency=medium

* New synapse release 1.56.0.

-- Synapse Packaging team <packages@matrix.org> Tue, 05 Apr 2022 12:38:39 +0100

matrix-synapse-py3 (1.56.0~rc1) stable; urgency=medium

* New synapse release 1.56.0~rc1.

-- Synapse Packaging team <packages@matrix.org> Tue, 29 Mar 2022 10:40:50 +0100

matrix-synapse-py3 (1.55.2) stable; urgency=medium

* New synapse release 1.55.2.

-- Synapse Packaging team <packages@matrix.org> Thu, 24 Mar 2022 19:07:11 +0000

matrix-synapse-py3 (1.55.1) stable; urgency=medium

* New synapse release 1.55.1.

-- Synapse Packaging team <packages@matrix.org> Thu, 24 Mar 2022 17:44:23 +0000

matrix-synapse-py3 (1.55.0) stable; urgency=medium

* New synapse release 1.55.0.

-- Synapse Packaging team <packages@matrix.org> Tue, 22 Mar 2022 13:59:26 +0000

matrix-synapse-py3 (1.55.0~rc1) stable; urgency=medium

* New synapse release 1.55.0~rc1.
Expand Down
1 change: 1 addition & 0 deletions demo/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ for port in 8080 8081 8082; do
printf '\n\n# Customisation made by demo/start.sh\n\n'
echo "public_baseurl: http://localhost:$port/"
echo 'enable_registration: true'
echo 'enable_registration_without_verification: true'
echo ''

# Warning, this heredoc depends on the interaction of tabs and spaces.
Expand Down
78 changes: 58 additions & 20 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,61 @@
# DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile --build-arg PYTHON_VERSION=3.10 .
#

# Irritatingly, there is no blessed guide on how to distribute an application with its
# poetry-managed environment in a docker image. We have opted for
# `poetry export | pip install -r /dev/stdin`, but there are known bugs in
# in `poetry export` whose fixes (scheduled for poetry 1.2) have yet to be released.
# In case we get bitten by those bugs in the future, the recommendations here might
# be useful:
# https://github.com/python-poetry/poetry/discussions/1879#discussioncomment-216865
# https://stackoverflow.com/questions/53835198/integrating-python-poetry-with-docker?answertab=scoredesc



ARG PYTHON_VERSION=3.9

###
### Stage 0: builder
### Stage 0: generate requirements.txt
###
FROM docker.io/python:${PYTHON_VERSION}-slim as builder
FROM docker.io/python:${PYTHON_VERSION}-slim as requirements

# install the OS build deps
#
# RUN --mount is specific to buildkit and is documented at
# https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount.
# Here we use it to set up a cache for apt, to improve rebuild speeds on
# slow connections.
# Here we use it to set up a cache for apt (and below for pip), to improve
# rebuild speeds on slow connections.
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*

# We install poetry in its own build stage to avoid its dependencies conflicting with
# synapse's dependencies.
# We use a specific commit from poetry's master branch instead of our usual 1.1.12,
# to incorporate fixes to some bugs in `poetry export`. This commit corresponds to
# https://github.com/python-poetry/poetry/pull/5156 and
# https://github.com/python-poetry/poetry/issues/5141 ;
# without it, we generate a requirements.txt with incorrect environment markers,
# which causes necessary packages to be omitted when we `pip install`.
#
# NB: In poetry 1.2 `poetry export` will be moved into a plugin; we'll need to also
# pip install poetry-plugin-export (https://github.com/python-poetry/poetry-plugin-export).
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --user git+https://github.com/python-poetry/poetry.git@fb13b3a676f476177f7937ffa480ee5cff9a90a5

WORKDIR /synapse

# Copy just what we need to run `poetry export`...
COPY pyproject.toml poetry.lock README.rst /synapse/

RUN /root/.local/bin/poetry export --extras all -o /synapse/requirements.txt

###
### Stage 1: builder
###
FROM docker.io/python:${PYTHON_VERSION}-slim as builder

# install the OS build deps
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Expand All @@ -45,30 +86,27 @@ RUN \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy just what we need to pip install
COPY MANIFEST.in README.rst setup.py /synapse/
COPY synapse/__init__.py /synapse/synapse/__init__.py
COPY synapse/python_dependencies.py /synapse/synapse/python_dependencies.py

# To speed up rebuilds, install all of the dependencies before we copy over
# the whole synapse project so that we this layer in the Docker cache can be
# the whole synapse project, so that this layer in the Docker cache can be
# used while you develop on the source
#
# This is aiming at installing the `install_requires` and `extras_require` from `setup.py`
# This is aiming at installing the `[tool.poetry.depdendencies]` from pyproject.toml.
COPY --from=requirements /synapse/requirements.txt /synapse/
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefix="/install" --no-warn-script-location \
/synapse[all]
pip install --prefix="/install" --no-warn-script-location -r /synapse/requirements.txt

# Copy over the rest of the project
# Copy over the rest of the synapse source code.
COPY synapse /synapse/synapse/
# ... and what we need to `pip install`.
# TODO: once pyproject.toml declares poetry-core as its build system, we'll need to copy
# pyproject.toml here, ditching setup.py and MANIFEST.in.
COPY setup.py MANIFEST.in README.rst /synapse/

# Install the synapse package itself and all of its children packages.
#
# This is aiming at installing only the `packages=find_packages(...)` from `setup.py
# Install the synapse package itself.
RUN pip install --prefix="/install" --no-deps --no-warn-script-location /synapse

###
### Stage 1: runtime
### Stage 2: runtime
###

FROM docker.io/python:${PYTHON_VERSION}-slim
Expand Down
Loading

0 comments on commit bd7303d

Please sign in to comment.