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

Commit 5b7796e

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 5b7796e

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-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: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,28 @@ 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
35+
# Copy just what we need to pip install
36+
COPY scripts /synapse/scripts/
37+
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
40+
# To speed up rebuilds, install all of the dependencies before we copy over
41+
# the whole synapse project so that we this layer in the Docker cache can be
42+
# used while you develop on the source
43+
#
44+
# This is aiming at installing the `install_requires` and `extras_require` from `setup.py`
3645
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
46+
/synapse[all]
5047

51-
# now install synapse and all of the python deps to /install.
48+
# Copy over the rest of the project
5249
COPY synapse /synapse/synapse/
53-
COPY scripts /synapse/scripts/
54-
COPY MANIFEST.in README.rst setup.py synctl /synapse/
5550

56-
RUN pip install --prefix="/install" --no-warn-script-location \
57-
/synapse[all]
51+
# Install the synapse package itself and all of its children packages.
52+
#
53+
# This is aiming at installing only the `packages=find_packages(...)` from `setup.py
54+
RUN pip install --prefix="/install" --no-deps --no-warn-script-location /synapse
5855

5956
###
6057
### Stage 1: runtime
@@ -70,7 +67,7 @@ RUN apt-get update && apt-get install -y \
7067
libwebp6 \
7168
xmlsec1 \
7269
libjemalloc2 \
73-
&& rm -rf /var/lib/apt/lists/*
70+
&& rm -rf /var/lib/apt/lists/*
7471

7572
COPY --from=builder /install /usr/local
7673
COPY ./docker/start.py /start.py
@@ -83,4 +80,4 @@ EXPOSE 8008/tcp 8009/tcp 8448/tcp
8380
ENTRYPOINT ["/start.py"]
8481

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

0 commit comments

Comments
 (0)