Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit fab17b9

Browse files
committed
Make pip install faster for Complement testing
Install dependencies before we copy over the whole project so that any change we make to the project source while developing does not invalidate the Docker layer cache where we installed all of the dependencies. This speeds up Docker rebuilds by a lot!
1 parent 7b06f85 commit fab17b9

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

changelog.d/9610.docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Speed up Docker builds and make it nicer to test against Complement while developing (install all dependencies before copying the project).

docker/Dockerfile

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,29 @@ RUN apt-get update && apt-get install -y \
3030
libxslt1-dev \
3131
rustc \
3232
zlib1g-dev \
33-
&& rm -rf /var/lib/apt/lists/*
33+
&& rm -rf /var/lib/apt/lists/*
3434

35-
# Build dependencies that are not available as wheels, to speed up rebuilds
36-
RUN pip install --prefix="/install" --no-warn-script-location \
37-
cryptography \
38-
frozendict \
39-
jaeger-client \
40-
opentracing \
41-
# Match the version constraints of Synapse
42-
"prometheus_client>=0.4.0" \
43-
psycopg2 \
44-
pycparser \
45-
pyrsistent \
46-
pyyaml \
47-
simplejson \
48-
threadloop \
49-
thrift
50-
51-
# now install synapse and all of the python deps to /install.
52-
COPY synapse /synapse/synapse/
35+
# Copy just what we need to pip install
5336
COPY scripts /synapse/scripts/
5437
COPY MANIFEST.in README.rst setup.py synctl /synapse/
38+
COPY synapse/__init__.py /synapse/synapse/__init__.py
39+
COPY synapse/python_dependencies.py /synapse/synapse/python_dependencies.py
5540

41+
# To speed up rebuilds, install all of the dependencies before we copy over
42+
# the whole synapse project so that we this layer in the Docker cache can be
43+
# used while you develop on the source
44+
#
45+
# This is aiming at installing the `install_requires` and `extras_require` from `setup.py`
5646
RUN pip install --prefix="/install" --no-warn-script-location \
57-
/synapse[all]
47+
/synapse[all]
48+
49+
# Copy over the rest of the project
50+
COPY synapse /synapse/synapse/
51+
52+
# Install the synapse package itself and all of its children packages.
53+
#
54+
# This is aiming at installing only the `packages=find_packages(...)` from `setup.py
55+
RUN pip install --prefix="/install" --no-deps --no-warn-script-location /synapse
5856

5957
###
6058
### Stage 1: runtime
@@ -70,7 +68,7 @@ RUN apt-get update && apt-get install -y \
7068
libwebp6 \
7169
xmlsec1 \
7270
libjemalloc2 \
73-
&& rm -rf /var/lib/apt/lists/*
71+
&& rm -rf /var/lib/apt/lists/*
7472

7573
COPY --from=builder /install /usr/local
7674
COPY ./docker/start.py /start.py
@@ -83,4 +81,4 @@ EXPOSE 8008/tcp 8009/tcp 8448/tcp
8381
ENTRYPOINT ["/start.py"]
8482

8583
HEALTHCHECK --interval=1m --timeout=5s \
86-
CMD curl -fSs http://localhost:8008/health || exit 1
84+
CMD curl -fSs http://localhost:8008/health || exit 1

0 commit comments

Comments
 (0)