1# DEV: Use `debian:slim` instead of an `alpine` image to support installing wheels from PyPI
2#      this drastically improves test execution time since python dependencies don't all
3#      have to be built from source all the time (grpcio takes forever to install)
4FROM debian:buster-slim
5
6# http://bugs.python.org/issue19846
7# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
8ENV LANG C.UTF-8
9
10# https://support.circleci.com/hc/en-us/articles/360045268074-Build-Fails-with-Too-long-with-no-output-exceeded-10m0s-context-deadline-exceeded-
11ENV PYTHONUNBUFFERED=1
12ENV NODE_VERSION=node_16.x
13
14RUN \
15  # Install system dependencies
16  apt-get update \
17  && apt-get install -y --no-install-recommends \
18      apt-transport-https \
19      build-essential \
20      ca-certificates \
21      clang-format \
22      curl \
23      git \
24      gnupg \
25      jq \
26      libbz2-dev \
27      libenchant-dev \
28      libffi-dev \
29      liblzma-dev \
30      libmariadb-dev \
31      libmariadb-dev-compat \
32      libmemcached-dev \
33      libmemcached-dev \
34      libncurses5-dev \
35      libncursesw5-dev \
36      libpq-dev \
37      libreadline-dev \
38      libsasl2-dev \
39      libsqlite3-dev \
40      libsqliteodbc \
41      libssh-dev \
42      libssl-dev \
43      patch \
44      python-openssl\
45      unixodbc-dev \
46      valgrind \
47      wget \
48      zlib1g-dev \
49  # Setup Node.js package repository
50  # DEV: The nodejs available with the main repo doesn't install npm
51  # https://github.com/nodesource/distributions/blob/025fe79908872abd39c590a45893b59929cb91e6/README.md#debmanual
52  && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
53  && echo "deb https://deb.nodesource.com/${NODE_VERSION} buster main" | tee /etc/apt/sources.list.d/nodesource.list \
54  && echo "deb-src https://deb.nodesource.com/${NODE_VERSION} buster main" | tee -a /etc/apt/sources.list.d/nodesource.list \
55  && apt-get update \
56  && apt-get install -y --no-install-recommends nodejs \
57  && apt-get install -y libmariadb3 \
58  # Cleaning up apt cache space
59  && rm -rf /var/lib/apt/lists/*
60
61
62# Configure PATH environment for pyenv
63ENV PYENV_ROOT /root/.pyenv
64ENV PATH ${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:$PATH
65
66# Install pyenv
67RUN git clone git://github.com/pyenv/pyenv.git "${PYENV_ROOT}"
68
69
70# Install all required python versions
71RUN \
72  pyenv install 2.7.18 \
73  && pyenv install 3.5.10 \
74  && pyenv install 3.6.12 \
75  && pyenv install 3.7.9 \
76  && pyenv install 3.8.7 \
77  && pyenv install 3.9.1 \
78  && pyenv install 3.10.0 \
79  # Order matters: first version is the global one
80  && pyenv global 3.9.1 2.7.18 3.5.10 3.6.12 3.7.9 3.8.7 3.10.0 \
81  && pip install --upgrade pip
82
83
84# Install sirun for running benchmarks
85# https://github.com/DataDog/sirun
86ENV SIRUN_VERSION=0.1.6
87RUN \
88  wget https://github.com/DataDog/sirun/releases/download/v${SIRUN_VERSION}/sirun-v${SIRUN_VERSION}-x86_64-unknown-linux-gnu.tar.gz \
89  && tar -C /usr/local/bin/ -zxf sirun-v${SIRUN_VERSION}-x86_64-unknown-linux-gnu.tar.gz \
90  && rm sirun-v${SIRUN_VERSION}-x86_64-unknown-linux-gnu.tar.gz
91
92# Install datadog-ci tool for uploading JUnit XML reports
93# https://www.npmjs.com/package/@datadog/datadog-ci
94RUN npm install -g @datadog/datadog-ci
95
96CMD ["/bin/bash"]
97