Dockerfile-dhvirtualenv 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. FROM ${distro} as builder
  17. RUN apt-get update -qq -o Acquire::Languages=none
  18. RUN env DEBIAN_FRONTEND=noninteractive apt-get install \
  19. -yqq --no-install-recommends \
  20. build-essential \
  21. ca-certificates \
  22. devscripts \
  23. equivs \
  24. wget
  25. # fetch and unpack the package
  26. RUN mkdir /dh-virtualenv
  27. RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/spotify/dh-virtualenv/archive/ac6e1b1.tar.gz
  28. RUN tar -xv --strip-components=1 -C /dh-virtualenv -f /dh-virtualenv.tar.gz
  29. # install its build deps. We do another apt-cache-update here, because we might
  30. # be using a stale cache from docker build.
  31. RUN apt-get update -qq -o Acquire::Languages=none \
  32. && cd /dh-virtualenv \
  33. && env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -y --no-install-recommends"
  34. # build it
  35. RUN cd /dh-virtualenv && dpkg-buildpackage -us -uc -b
  36. ###
  37. ### Stage 1
  38. ###
  39. FROM ${distro}
  40. # Get the distro we want to pull from as a dynamic build variable
  41. # (We need to define it in each build stage)
  42. ARG distro=""
  43. ENV distro ${distro}
  44. # Python < 3.7 assumes LANG="C" means ASCII-only and throws on printing unicode
  45. # http://bugs.python.org/issue19846
  46. ENV LANG C.UTF-8
  47. # Install the build dependencies
  48. #
  49. # NB: keep this list in sync with the list of build-deps in debian/control
  50. # TODO: it would be nice to do that automatically.
  51. # TODO: Remove the dh-systemd stanza after dropping support for Ubuntu xenial
  52. # it's a transitional package on all other, more recent releases
  53. RUN apt-get update -qq -o Acquire::Languages=none \
  54. && env DEBIAN_FRONTEND=noninteractive apt-get install \
  55. -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
  56. build-essential \
  57. debhelper \
  58. devscripts \
  59. libsystemd-dev \
  60. lsb-release \
  61. pkg-config \
  62. python3-dev \
  63. python3-pip \
  64. python3-setuptools \
  65. python3-venv \
  66. sqlite3 \
  67. libpq-dev \
  68. xmlsec1 \
  69. && ( env DEBIAN_FRONTEND=noninteractive apt-get install \
  70. -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
  71. dh-systemd || true )
  72. COPY --from=builder /dh-virtualenv_1.2~dev-1_all.deb /
  73. # install dhvirtualenv. Update the apt cache again first, in case we got a
  74. # cached cache from docker the first time.
  75. RUN apt-get update -qq -o Acquire::Languages=none \
  76. && apt-get install -yq /dh-virtualenv_1.2~dev-1_all.deb
  77. WORKDIR /synapse/source
  78. ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"]