2018-01-30 20:17:30 +01:00
|
|
|
# Dockerfile for a generic Ubuntu image with just the basics we need
|
2017-09-20 01:36:00 +02:00
|
|
|
# to make it suitable for CI. In particular:
|
|
|
|
# * a non-root user to run as (a pain to try to do in setup,
|
|
|
|
# because by then we've already cloned the repo);
|
|
|
|
# * Git and other basic utilities.
|
|
|
|
#
|
|
|
|
# Based on CircleCI's provided images, but those are on Debian Jessie
|
|
|
|
# and we want Ubuntu, to match our supported environments in production.
|
|
|
|
# See these templates and code:
|
|
|
|
# https://github.com/circleci/circleci-images/blob/1949c44df/shared/images/
|
|
|
|
# which we've borrowed from, chiefly Dockerfile-basic.template.
|
|
|
|
#
|
|
|
|
# The CircleCI `python` images are based on upstream's `python` (i.e.,
|
|
|
|
# https://hub.docker.com/_/python/), which also come only for Debian
|
|
|
|
# (and various obscure distros, and Windows) and not Ubuntu. Those
|
|
|
|
# are in turn based on upstream's `buildpack-deps`, which do come in
|
|
|
|
# Ubuntu flavors.
|
|
|
|
#
|
|
|
|
# So this image starts from `buildpack-deps`, does the job of `python`
|
|
|
|
# (but much simpler, with a couple of packages from the distro), and
|
|
|
|
# then borrows from the CircleCI Dockerfile.
|
|
|
|
|
2020-06-23 21:36:39 +02:00
|
|
|
# To rebuild from this file for a given release, say bionic:
|
|
|
|
# 0. $ tools/ci/generate-dockerfiles
|
|
|
|
# 1. pick a new image name, like `gregprice/actions:bionic`
|
|
|
|
# 2. $ sudo docker build tools/ci/images/$RELEASE/ --tag $NAME
|
2018-01-30 20:17:30 +01:00
|
|
|
# 3. $ sudo docker push $NAME
|
2020-06-23 21:36:39 +02:00
|
|
|
# 4. update .github/workflows/zulip-ci.yml to refer to the new name
|
2017-12-02 02:13:26 +01:00
|
|
|
|
2018-01-30 20:17:30 +01:00
|
|
|
FROM {base_image}
|
2017-09-20 01:36:00 +02:00
|
|
|
|
|
|
|
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \
|
|
|
|
&& echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
2018-01-30 22:01:54 +01:00
|
|
|
sudo \
|
|
|
|
locales \
|
2017-09-20 01:42:18 +02:00
|
|
|
xvfb \
|
2017-09-20 01:55:30 +02:00
|
|
|
parallel \
|
2020-09-03 04:40:56 +02:00
|
|
|
unzip zip jq \
|
2017-09-20 01:55:30 +02:00
|
|
|
python3-pip \
|
2017-09-20 01:37:19 +02:00
|
|
|
&& ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime \
|
2018-01-30 20:17:30 +01:00
|
|
|
&& {{ locale-gen en_US.UTF-8 || true; }} \
|
2017-12-13 20:52:16 +01:00
|
|
|
&& echo "LC_ALL=en_US.UTF-8" | sudo tee -a /etc/default/locale
|
|
|
|
|
|
|
|
# Set the locale, together with the locale-related steps above.
|
|
|
|
# It's not entirely clear why, but alternatives that don't work include
|
|
|
|
# * using `C.UTF-8` instead of `en_US.UTF-8`, here and above
|
2020-07-07 23:19:13 +02:00
|
|
|
# (causes mysterious failures in zerver.tests.test_message_fetch)
|
2017-12-13 20:52:16 +01:00
|
|
|
# * skipping the /etc/default/locale step above (ditto)
|
|
|
|
# * skipping this ENV instruction (causes provision to fail,
|
|
|
|
# because Python tries to use the `ascii` codec)
|
|
|
|
# Details in https://github.com/zulip/zulip/pull/7762#issuecomment-353197289
|
|
|
|
# and particularly https://circleci.com/gh/hackerkid/zulip/80 .
|
|
|
|
ENV LC_ALL en_US.UTF-8
|
2017-09-20 01:36:00 +02:00
|
|
|
|
|
|
|
# Install Docker. This logic comes from Circle's Dockerfile; it's probably
|
|
|
|
# faster than the upstream-recommended approach of using their apt repo,
|
|
|
|
# and fine for an image that will be rebuilt rather than upgraded.
|
|
|
|
|
|
|
|
# Docker core...
|
2017-12-02 01:35:42 +01:00
|
|
|
RUN set -e \
|
2017-09-20 01:36:00 +02:00
|
|
|
&& export DOCKER_VERSION=$(curl --silent --fail --retry 3 https://download.docker.com/linux/static/stable/x86_64/ | grep -o -e 'docker-[.0-9]*-ce\.tgz' | sort -r | head -n 1) \
|
2018-01-30 20:17:30 +01:00
|
|
|
&& DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${{DOCKER_VERSION}}" \
|
2017-09-20 01:36:00 +02:00
|
|
|
&& echo Docker URL: $DOCKER_URL \
|
2018-01-30 20:17:30 +01:00
|
|
|
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${{DOCKER_URL}}" \
|
2017-09-20 01:36:00 +02:00
|
|
|
&& ls -lha /tmp/docker.tgz \
|
|
|
|
&& tar -xz -C /tmp -f /tmp/docker.tgz \
|
|
|
|
&& mv /tmp/docker/* /usr/bin \
|
|
|
|
&& rm -rf /tmp/docker /tmp/docker.tgz \
|
|
|
|
&& which docker \
|
2017-12-02 01:35:42 +01:00
|
|
|
&& (docker version 2>/dev/null || true)
|
2017-09-20 01:36:00 +02:00
|
|
|
|
|
|
|
# ...docker-compose...
|
|
|
|
RUN COMPOSE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/docker-compose-latest" \
|
|
|
|
&& curl --silent --show-error --location --fail --retry 3 --output /usr/bin/docker-compose $COMPOSE_URL \
|
|
|
|
&& chmod +x /usr/bin/docker-compose \
|
|
|
|
&& docker-compose version
|
|
|
|
|
|
|
|
# ... and dockerize.
|
|
|
|
RUN DOCKERIZE_URL="https://circle-downloads.s3.amazonaws.com/circleci-images/cache/linux-amd64/dockerize-latest.tar.gz" \
|
|
|
|
&& curl --silent --show-error --location --fail --retry 3 --output /tmp/dockerize-linux-amd64.tar.gz $DOCKERIZE_URL \
|
|
|
|
&& tar -C /usr/local/bin -xzvf /tmp/dockerize-linux-amd64.tar.gz \
|
|
|
|
&& rm -rf /tmp/dockerize-linux-amd64.tar.gz \
|
|
|
|
&& dockerize --version
|
|
|
|
|
2017-09-20 03:37:30 +02:00
|
|
|
# Extra packages used by Zulip.
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends \
|
2019-06-29 10:26:57 +02:00
|
|
|
memcached rabbitmq-server redis-server \
|
2019-07-18 11:37:05 +02:00
|
|
|
hunspell-en-us supervisor libssl-dev puppet \
|
2020-06-24 15:39:19 +02:00
|
|
|
gettext libffi-dev libfreetype6-dev zlib1g-dev \
|
2020-05-09 22:23:33 +02:00
|
|
|
libjpeg-dev libldap2-dev \
|
2020-07-25 21:25:25 +02:00
|
|
|
libxml2-dev libxslt1-dev libpq-dev moreutils
|
2017-09-20 03:37:30 +02:00
|
|
|
|
2020-07-04 22:09:45 +02:00
|
|
|
# Upgrade git if it is less than v2.18 because GitHub Actions'
|
|
|
|
# checkout installs source code using Rest API as an optimization
|
|
|
|
# if the version is less than v2.18, which causes failure in provision
|
|
|
|
# and tests because of the lack of git being initialized.
|
|
|
|
RUN export git_version=$(git --version | cut -d ' ' -f3 | cut -d 'v' -f2) && \
|
|
|
|
if dpkg --compare-versions $git_version lt 2.18; then \
|
|
|
|
sudo apt-get install -y software-properties-common && \
|
|
|
|
sudo add-apt-repository ppa:git-core/ppa -y && \
|
|
|
|
sudo apt-get update && \
|
|
|
|
sudo apt-get install -y git; \
|
|
|
|
fi
|
|
|
|
|
2020-06-26 20:41:34 +02:00
|
|
|
ARG USERNAME=github
|
|
|
|
RUN groupadd --gid 3434 $USERNAME \
|
|
|
|
&& useradd --uid 3434 --gid $USERNAME --shell /bin/bash --create-home $USERNAME \
|
|
|
|
&& echo "$USERNAME ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers.d/50-$USERNAME \
|
2017-09-20 01:36:00 +02:00
|
|
|
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
|
|
|
|
|
2020-06-26 20:41:34 +02:00
|
|
|
USER $USERNAME
|
2017-09-20 01:36:00 +02:00
|
|
|
|
|
|
|
CMD ["/bin/sh"]
|