2018-12-20 06:33:29 -05:00
|
|
|
# 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=""
|
2019-01-02 02:17:39 -05:00
|
|
|
|
|
|
|
###
|
|
|
|
### Stage 0: build a dh-virtualenv
|
|
|
|
###
|
2021-07-21 16:25:28 -04:00
|
|
|
|
2022-01-03 14:17:16 -05:00
|
|
|
# This is only really needed on focal, since other distributions we
|
2021-07-21 16:25:28 -04:00
|
|
|
# care about have a recent version of dh-virtualenv by default. Unfortunately,
|
|
|
|
# it looks like focal is going to be with us for a while.
|
|
|
|
#
|
|
|
|
# (focal doesn't have a dh-virtualenv package at all. There is a PPA at
|
|
|
|
# https://launchpad.net/~jyrki-pulliainen/+archive/ubuntu/dh-virtualenv, but
|
|
|
|
# it's not obviously easier to use that than to build our own.)
|
|
|
|
|
2023-05-31 11:13:31 -04:00
|
|
|
FROM docker.io/library/${distro} as builder
|
2019-01-02 02:17:39 -05:00
|
|
|
|
|
|
|
RUN apt-get update -qq -o Acquire::Languages=none
|
|
|
|
RUN env DEBIAN_FRONTEND=noninteractive apt-get install \
|
2023-07-05 19:45:42 -04:00
|
|
|
-yqq --no-install-recommends \
|
|
|
|
build-essential \
|
|
|
|
ca-certificates \
|
|
|
|
devscripts \
|
|
|
|
equivs \
|
|
|
|
wget
|
2019-01-02 02:17:39 -05:00
|
|
|
|
|
|
|
# fetch and unpack the package
|
2023-01-04 11:26:29 -05:00
|
|
|
# We are temporarily using a fork of dh-virtualenv due to an incompatibility with Python 3.11, which ships with
|
|
|
|
# Debian sid. TODO: Switch back to upstream once https://github.com/spotify/dh-virtualenv/pull/354 has merged.
|
2020-05-19 08:48:41 -04:00
|
|
|
RUN mkdir /dh-virtualenv
|
2023-01-04 11:26:29 -05:00
|
|
|
RUN wget -q -O /dh-virtualenv.tar.gz https://github.com/matrix-org/dh-virtualenv/archive/refs/tags/matrixorg-2023010302.tar.gz
|
2020-05-19 08:48:41 -04:00
|
|
|
RUN tar -xv --strip-components=1 -C /dh-virtualenv -f /dh-virtualenv.tar.gz
|
2019-01-02 02:17:39 -05:00
|
|
|
|
2020-05-22 05:17:47 -04:00
|
|
|
# install its build deps. We do another apt-cache-update here, because we might
|
|
|
|
# be using a stale cache from docker build.
|
|
|
|
RUN apt-get update -qq -o Acquire::Languages=none \
|
|
|
|
&& cd /dh-virtualenv \
|
2020-05-19 08:48:41 -04:00
|
|
|
&& env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -y --no-install-recommends"
|
2019-01-02 02:17:39 -05:00
|
|
|
|
2021-09-28 07:13:51 -04:00
|
|
|
# Build it. Note that building the docs doesn't work due to differences in
|
|
|
|
# Sphinx APIs across versions/distros.
|
|
|
|
RUN cd /dh-virtualenv && DEB_BUILD_OPTIONS=nodoc dpkg-buildpackage -us -uc -b
|
2019-01-02 02:17:39 -05:00
|
|
|
|
|
|
|
###
|
|
|
|
### Stage 1
|
|
|
|
###
|
2023-05-31 11:13:31 -04:00
|
|
|
FROM docker.io/library/${distro}
|
2018-12-20 06:33:29 -05:00
|
|
|
|
2019-07-29 10:33:32 -04:00
|
|
|
# Get the distro we want to pull from as a dynamic build variable
|
|
|
|
# (We need to define it in each build stage)
|
|
|
|
ARG distro=""
|
|
|
|
ENV distro ${distro}
|
|
|
|
|
2018-12-20 06:33:29 -05:00
|
|
|
# Install the build dependencies
|
2019-07-17 12:47:07 -04:00
|
|
|
#
|
|
|
|
# NB: keep this list in sync with the list of build-deps in debian/control
|
|
|
|
# TODO: it would be nice to do that automatically.
|
2018-12-20 06:33:29 -05:00
|
|
|
RUN apt-get update -qq -o Acquire::Languages=none \
|
|
|
|
&& env DEBIAN_FRONTEND=noninteractive apt-get install \
|
2023-07-05 19:45:42 -04:00
|
|
|
-yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \
|
|
|
|
build-essential \
|
|
|
|
curl \
|
|
|
|
debhelper \
|
|
|
|
devscripts \
|
|
|
|
libsystemd-dev \
|
|
|
|
lsb-release \
|
|
|
|
pkg-config \
|
|
|
|
python3-dev \
|
|
|
|
python3-pip \
|
|
|
|
python3-setuptools \
|
|
|
|
python3-venv \
|
|
|
|
sqlite3 \
|
|
|
|
libpq-dev \
|
|
|
|
libicu-dev \
|
|
|
|
pkg-config \
|
|
|
|
xmlsec1
|
2019-01-02 02:17:39 -05:00
|
|
|
|
2022-09-06 14:01:37 -04:00
|
|
|
# Install rust and ensure it's in the PATH
|
|
|
|
ENV RUSTUP_HOME=/rust
|
|
|
|
ENV CARGO_HOME=/cargo
|
|
|
|
ENV PATH=/cargo/bin:/rust/bin:$PATH
|
|
|
|
RUN mkdir /rust /cargo
|
|
|
|
|
2022-10-12 05:47:02 -04:00
|
|
|
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
|
2022-09-06 14:01:37 -04:00
|
|
|
|
|
|
|
|
2022-01-03 14:17:16 -05:00
|
|
|
COPY --from=builder /dh-virtualenv_1.2.2-1_all.deb /
|
2019-02-14 12:29:40 -05:00
|
|
|
|
|
|
|
# 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 \
|
2022-01-03 14:17:16 -05:00
|
|
|
&& apt-get install -yq /dh-virtualenv_1.2.2-1_all.deb
|
2018-12-20 06:33:29 -05:00
|
|
|
|
|
|
|
WORKDIR /synapse/source
|
|
|
|
ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"]
|