From 4ca87d785b3697e03d1327a094d561bb516de5d5 Mon Sep 17 00:00:00 2001 From: Gaurav Pandey Date: Wed, 2 Jun 2021 23:05:03 +0530 Subject: [PATCH] ci: Create Zulip server pre-installed docker image template. These Docker images will be useful for testing the upgrade process from previous Zulip major releases to master. Fixes part of #18346. --- tools/ci/Dockerfile.prod.template | 30 ++++++++++++++++++++++++++++++ tools/ci/Dockerfile.template | 6 +++--- tools/ci/generate-dockerfiles | 20 ++++++++++++++++++-- tools/ci/images.yml | 21 +++++++++++++-------- 4 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 tools/ci/Dockerfile.prod.template diff --git a/tools/ci/Dockerfile.prod.template b/tools/ci/Dockerfile.prod.template new file mode 100644 index 0000000000..d4542652b8 --- /dev/null +++ b/tools/ci/Dockerfile.prod.template @@ -0,0 +1,30 @@ +# To build these production upgrade test images, say a Debian Buster system +# preinstalled with Zulip 3.4 (RELEASE=buster, VERSION=3.4): +# 0. $ tools/ci/generate-dockerfiles # Defined in tools/ci/images.yml +# 1. $ docker build tools/ci/images/$RELEASE-$VERSION/ --tag zulip/ci:$RELEASE-$VERSION +# 2. $ docker push zulip/ci:$RELEASE-$VERSION + +FROM {base_image} + +# Remove already existing rabbitmq mnesia directory files +RUN sudo rm -rf /var/lib/rabbitmq/mnesia/* + +# The bionic hack used in production suite +RUN if [ -f /etc/os-release ]; then \ + . /etc/os-release \ + && os_codename=$VERSION_CODENAME \ + && if [ "$os_codename" = "bionic" ]; then \ + sudo sed -i '/^bind/s/bind.*/bind 0.0.0.0/' /etc/redis/redis.conf; \ + fi; \ + fi + + +# Download the release tarball, start rabbitmq server and install the server +RUN cd $(mktemp -d) \ + && wget https://www.zulip.org/dist/releases/zulip-server-{version}.tar.gz \ + && tar -xf zulip-server-{version}.tar.gz \ + && sudo service rabbitmq-server start \ + && sudo service rabbitmq-server status \ + && sudo -s ./zulip-server-{version}/scripts/setup/install --self-signed-cert --hostname 127.0.0.1 --email circleci@example.com + +CMD ["/bin/sh"] diff --git a/tools/ci/Dockerfile.template b/tools/ci/Dockerfile.template index ab9222ea8c..38fec9c225 100644 --- a/tools/ci/Dockerfile.template +++ b/tools/ci/Dockerfile.template @@ -21,9 +21,9 @@ # then borrows from the CircleCI Dockerfile. # To rebuild from this file for a given release, say bionic: -# 0. $ tools/ci/generate-dockerfiles -# 1. $ docker build tools/ci/images/$RELEASE/ --tag zulip/ci:$RELEASE -# 2. $ docker push zulip/ci:$RELEASE +# 1. $ tools/ci/generate-dockerfiles +# 2. $ docker build tools/ci/images/$RELEASE/ --tag zulip/ci:$RELEASE +# 3. $ docker push zulip/ci:$RELEASE FROM {base_image} diff --git a/tools/ci/generate-dockerfiles b/tools/ci/generate-dockerfiles index e6302e59a0..bd674866e8 100755 --- a/tools/ci/generate-dockerfiles +++ b/tools/ci/generate-dockerfiles @@ -10,10 +10,13 @@ if __name__ == "__main__": with open("Dockerfile.template") as f: docker_template = f.read() + with open("Dockerfile.prod.template") as p: + docker_prod_template = p.read() + with open("images.yml") as f: dockerfile_settings = yaml.safe_load(f) - for distro in dockerfile_settings: + for distro in dockerfile_settings["distros"]: dockerfile_path = f"images/{distro}/Dockerfile" os.makedirs(os.path.dirname(dockerfile_path), exist_ok=True) with open(dockerfile_path, "w") as f: @@ -24,4 +27,17 @@ if __name__ == "__main__": """ ) - f.write(docker_template.format_map(dockerfile_settings[distro])) + f.write(docker_template.format_map(dockerfile_settings["distros"][distro])) + + for server in dockerfile_settings["servers"]: + dockerfile_path = f"images/{server}/Dockerfile" + os.makedirs(os.path.dirname(dockerfile_path), exist_ok=True) + with open(dockerfile_path, "w") as f: + f.write( + """\ +# THIS IS A GENERATED FILE. DO NOT EDIT. +# See template: tools/ci/Dockerfile.prod.template + +""" + ) + f.write(docker_prod_template.format_map(dockerfile_settings["servers"][server])) diff --git a/tools/ci/images.yml b/tools/ci/images.yml index 7e4eb9b36f..b758494090 100644 --- a/tools/ci/images.yml +++ b/tools/ci/images.yml @@ -1,11 +1,16 @@ -bionic: - base_image: buildpack-deps:bionic-scm +distros: + bionic: + base_image: buildpack-deps:bionic-scm -focal: - base_image: buildpack-deps:focal-scm + focal: + base_image: buildpack-deps:focal-scm -buster: - base_image: buildpack-deps:buster-scm + buster: + base_image: buildpack-deps:buster-scm -bullseye: - base_image: buildpack-deps:bullseye-scm + bullseye: + base_image: buildpack-deps:bullseye-scm +servers: + buster-3.4: + base_image: zulip/ci:buster + version: 3.4