You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
3.7 KiB

  1. # A dockerfile which builds a docker image for building a debian package for
  2. # synapse. The distro to build for is passed as a docker build var.
  3. #
  4. # The default entrypoint expects the synapse source to be mounted as a
  5. # (read-only) volume at /synapse/source, and an output directory at /debs.
  6. #
  7. # A pair of environment variables (TARGET_USERID and TARGET_GROUPID) can be
  8. # passed to the docker container; if these are set, the build script will chown
  9. # the build products accordingly, to avoid ending up with things owned by root
  10. # in the host filesystem.
  11. # Get the distro we want to pull from as a dynamic build variable
  12. ARG distro=""
  13. ###
  14. ### Stage 0: build a dh-virtualenv
  15. ###
  16. # This is only really needed on focal, since other distributions we
  17. # care about have a recent version of dh-virtualenv by default. Unfortunately,
  18. # it looks like focal is going to be with us for a while.
  19. #
  20. # (focal doesn't have a dh-virtualenv package at all. There is a PPA at
  21. # https://launchpad.net/~jyrki-pulliainen/+archive/ubuntu/dh-virtualenv, but
  22. # it's not obviously easier to use that than to build our own.)
  23. FROM docker.io/library/${distro} as builder
  24. RUN apt-get update -qq -o Acquire::Languages=none
  25. RUN env DEBIAN_FRONTEND=noninteractive apt-get install \
  26. -yqq --no-install-recommends \
  27. build-essential \
  28. ca-certificates \
  29. devscripts \
  30. equivs \
  31. wget
  32. # fetch and unpack the package
  33. # We are temporarily using a fork of dh-virtualenv due to an incompatibility with Python 3.11, which ships with
  34. # Debian sid. TODO: Switch back to upstream once https://github.com/spotify/dh-virtualenv/pull/354 has merged.
  35. RUN mkdir /dh-virtualenv
  36. RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/matrix-org/dh-virtualenv/archive/refs/tags/matrixorg-2023010302.tar.gz
  37. RUN tar -xv --strip-components=1 -C /dh-virtualenv -f /dh-virtualenv.tar.gz
  38. # install its build deps. We do another apt-cache-update here, because we might
  39. # be using a stale cache from docker build.
  40. RUN apt-get update -qq -o Acquire::Languages=none \
  41. && cd /dh-virtualenv \
  42. && env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -y --no-install-recommends"
  43. # Build it. Note that building the docs doesn't work due to differences in
  44. # Sphinx APIs across versions/distros.
  45. RUN cd /dh-virtualenv && DEB_BUILD_OPTIONS=nodoc dpkg-buildpackage -us -uc -b
  46. ###
  47. ### Stage 1
  48. ###
  49. FROM docker.io/library/${distro}
  50. # Get the distro we want to pull from as a dynamic build variable
  51. # (We need to define it in each build stage)
  52. ARG distro=""
  53. ENV distro ${distro}
  54. # Install the build dependencies
  55. #
  56. # NB: keep this list in sync with the list of build-deps in debian/control
  57. # TODO: it would be nice to do that automatically.
  58. RUN apt-get update -qq -o Acquire::Languages=none \
  59. && env DEBIAN_FRONTEND=noninteractive apt-get install \
  60. -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
  61. build-essential \
  62. curl \
  63. debhelper \
  64. devscripts \
  65. libsystemd-dev \
  66. lsb-release \
  67. pkg-config \
  68. python3-dev \
  69. python3-pip \
  70. python3-setuptools \
  71. python3-venv \
  72. sqlite3 \
  73. libpq-dev \
  74. libicu-dev \
  75. pkg-config \
  76. xmlsec1
  77. # Install rust and ensure it's in the PATH
  78. ENV RUSTUP_HOME=/rust
  79. ENV CARGO_HOME=/cargo
  80. ENV PATH=/cargo/bin:/rust/bin:$PATH
  81. RUN mkdir /rust /cargo
  82. RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
  83. COPY --from=builder /dh-virtualenv_1.2.2-1_all.deb /
  84. # install dhvirtualenv. Update the apt cache again first, in case we got a
  85. # cached cache from docker the first time.
  86. RUN apt-get update -qq -o Acquire::Languages=none \
  87. && apt-get install -yq /dh-virtualenv_1.2.2-1_all.deb
  88. WORKDIR /synapse/source
  89. ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"]