From 1a6d5bfa08b4ba618dcab68e4ed524c4db07da2b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 20 Dec 2018 11:33:29 +0000 Subject: Debian packaging via dh_virtualenv (#4285) --- docker/Dockerfile-dhvirtualenv | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docker/Dockerfile-dhvirtualenv (limited to 'docker/Dockerfile-dhvirtualenv') diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv new file mode 100644 index 0000000000..ea6b650af2 --- /dev/null +++ b/docker/Dockerfile-dhvirtualenv @@ -0,0 +1,35 @@ +# A dockerfile which builds a docker image for building a debian package for +# synapse. The distro to build for is passed as a docker build var. +# +# The default entrypoint expects the synapse source to be mounted as a +# (read-only) volume at /synapse/source, and an output directory at /debs. +# +# A pair of environment variables (TARGET_USERID and TARGET_GROUPID) can be +# passed to the docker container; if these are set, the build script will chown +# the build products accordingly, to avoid ending up with things owned by root +# in the host filesystem. + +# Get the distro we want to pull from as a dynamic build variable +ARG distro="" +FROM ${distro} + +# Install the build dependencies +RUN apt-get update -qq -o Acquire::Languages=none \ + && env DEBIAN_FRONTEND=noninteractive apt-get install \ + -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ + build-essential \ + debhelper \ + devscripts \ + dh-systemd \ + dh-virtualenv \ + equivs \ + lsb-release \ + python3-dev \ + python3-pip \ + python3-setuptools \ + python3-venv \ + sqlite3 \ + wget + +WORKDIR /synapse/source +ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"] -- cgit 1.4.1 From 7134832c017fab1e4e6b90df9ad39dd618656427 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 2 Jan 2019 07:17:39 +0000 Subject: Install the optional dependencies into the debian package (#4325) since #4298, the optional dependencies are no longer installed with a simple `pip install .`, which meant that they were not being included in the debian package. The easy fix to that is dh_virtualenv --extras, but that needs dh_virtualenv 1.1... --- changelog.d/4325.feature | 1 + debian/build_virtualenv | 3 ++- debian/control | 2 +- docker/Dockerfile-dhvirtualenv | 37 +++++++++++++++++++++++++++++++++---- docker/build_debian.sh | 14 -------------- 5 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 changelog.d/4325.feature (limited to 'docker/Dockerfile-dhvirtualenv') diff --git a/changelog.d/4325.feature b/changelog.d/4325.feature new file mode 100644 index 0000000000..05ad70fe72 --- /dev/null +++ b/changelog.d/4325.feature @@ -0,0 +1 @@ +Synapse can now have its conditional/extra dependencies installed by pip. This functionality can be used by using `pip install matrix-synapse[feature]`, where feature is a comma separated list with the possible values "email.enable_notifs", "ldap3", "postgres", "saml2", "url_preview", and "test". If you want to install all optional dependencies, you can use "all" instead. diff --git a/debian/build_virtualenv b/debian/build_virtualenv index 61ffb13192..e9ef245476 100755 --- a/debian/build_virtualenv +++ b/debian/build_virtualenv @@ -33,7 +33,8 @@ dh_virtualenv \ --preinstall="lxml" \ --preinstall="mock" \ --extra-pip-arg="--no-cache-dir" \ - --extra-pip-arg="--compile" + --extra-pip-arg="--compile" \ + --extras="all" # we copy the tests to a temporary directory so that we can put them on the # PYTHONPATH without putting the uninstalled synapse on the pythonpath. diff --git a/debian/control b/debian/control index 552a81dcb0..9606a4c135 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: Synapse Packaging team Build-Depends: debhelper (>= 9), dh-systemd, - dh-virtualenv (>= 1.0), + dh-virtualenv (>= 1.1), lsb-release, python3-dev, python3, diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index ea6b650af2..ab28e49291 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -11,6 +11,35 @@ # Get the distro we want to pull from as a dynamic build variable ARG distro="" + +### +### Stage 0: build a dh-virtualenv +### +FROM ${distro} as builder + +RUN apt-get update -qq -o Acquire::Languages=none +RUN env DEBIAN_FRONTEND=noninteractive apt-get install \ + -yqq --no-install-recommends \ + build-essential \ + ca-certificates \ + devscripts \ + equivs \ + wget + +# fetch and unpack the package +RUN wget -q -O /dh-virtuenv-1.1.tar.gz https://github.com/spotify/dh-virtualenv/archive/1.1.tar.gz +RUN tar xvf /dh-virtuenv-1.1.tar.gz + +# install its build deps +RUN cd dh-virtualenv-1.1/ \ + && env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -yqq --no-install-recommends" + +# build it +RUN cd dh-virtualenv-1.1 && dpkg-buildpackage -us -uc -b + +### +### Stage 1 +### FROM ${distro} # Install the build dependencies @@ -21,15 +50,15 @@ RUN apt-get update -qq -o Acquire::Languages=none \ debhelper \ devscripts \ dh-systemd \ - dh-virtualenv \ - equivs \ lsb-release \ python3-dev \ python3-pip \ python3-setuptools \ python3-venv \ - sqlite3 \ - wget + sqlite3 + +COPY --from=builder /dh-virtualenv_1.1-1_all.deb / +RUN apt-get install -yq /dh-virtualenv_1.1-1_all.deb WORKDIR /synapse/source ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"] diff --git a/docker/build_debian.sh b/docker/build_debian.sh index cea5067fe9..6ed2b39898 100644 --- a/docker/build_debian.sh +++ b/docker/build_debian.sh @@ -6,20 +6,6 @@ set -ex DIST=`lsb_release -c -s` -# We need to build a newer dh_virtualenv on older OSes like Xenial. -if [ "$DIST" = 'xenial' ]; then - mkdir -p /tmp/dhvenv - cd /tmp/dhvenv - wget https://github.com/spotify/dh-virtualenv/archive/1.1.tar.gz - tar xvf 1.1.tar.gz - cd dh-virtualenv-1.1/ - env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io" - dpkg-buildpackage -us -uc -b - cd /tmp/dhvenv - apt-get install -yqq ./dh-virtualenv_1.1-1_all.deb -fi - - # we get a read-only copy of the source: make a writeable copy cp -aT /synapse/source /synapse/build cd /synapse/build -- cgit 1.4.1 From 649fe1c2be69676ffd73c9ad1807ea0bc747b003 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 14 Feb 2019 17:29:40 +0000 Subject: Fix debian build dockerfile Make sure it refreshes the apt cache before trying to install stuff --- docker/Dockerfile-dhvirtualenv | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'docker/Dockerfile-dhvirtualenv') diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index ab28e49291..224c92352d 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -58,7 +58,11 @@ RUN apt-get update -qq -o Acquire::Languages=none \ sqlite3 COPY --from=builder /dh-virtualenv_1.1-1_all.deb / -RUN apt-get install -yq /dh-virtualenv_1.1-1_all.deb + +# install dhvirtualenv. Update the apt cache again first, in case we got a +# cached cache from docker the first time. +RUN apt-get update -qq -o Acquire::Languages=none \ + && apt-get install -yq /dh-virtualenv_1.1-1_all.deb WORKDIR /synapse/source ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"] -- cgit 1.4.1