diff --git a/tools/ci/Dockerfile.template b/tools/ci/Dockerfile similarity index 95% rename from tools/ci/Dockerfile.template rename to tools/ci/Dockerfile index 38fec9c225..f712669c02 100644 --- a/tools/ci/Dockerfile.template +++ b/tools/ci/Dockerfile @@ -21,11 +21,11 @@ # then borrows from the CircleCI Dockerfile. # To rebuild from this file for a given release, say bionic: -# 1. $ tools/ci/generate-dockerfiles -# 2. $ docker build tools/ci/images/$RELEASE/ --tag zulip/ci:$RELEASE -# 3. $ docker push zulip/ci:$RELEASE +# docker build . --build-arg=BASE_IMAGE=buildpack-deps:bionic-scm --pull --tag=zulip/ci:bionic +# docker push zulip/ci:bionic -FROM {base_image} +ARG BASE_IMAGE +FROM $BASE_IMAGE RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \ && echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci @@ -52,9 +52,9 @@ ENV LC_ALL C.UTF-8 # Docker core... RUN set -e \ && 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) \ - && DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${{DOCKER_VERSION}}" \ + && DOCKER_URL="https://download.docker.com/linux/static/stable/x86_64/${DOCKER_VERSION}" \ && echo Docker URL: $DOCKER_URL \ - && curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${{DOCKER_URL}}" \ + && curl --silent --show-error --location --fail --retry 3 --output /tmp/docker.tgz "${DOCKER_URL}" \ && ls -lha /tmp/docker.tgz \ && tar -xz -C /tmp -f /tmp/docker.tgz \ && mv /tmp/docker/* /usr/bin \ diff --git a/tools/ci/Dockerfile.prod.template b/tools/ci/Dockerfile.prod similarity index 51% rename from tools/ci/Dockerfile.prod.template rename to tools/ci/Dockerfile.prod index 10ad8f279b..e3ebf1724e 100644 --- a/tools/ci/Dockerfile.prod.template +++ b/tools/ci/Dockerfile.prod @@ -1,10 +1,10 @@ # 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 +# preinstalled with Zulip 3.4: +# docker build . -f Dockerfile.prod --build-arg=BASE_IMAGE=zulip/ci:buster --build-arg=VERSION=3.4 --tag=zulip/ci:buster-3.4 +# docker push zulip/ci:buster-3.4 -FROM {base_image} +ARG BASE_IMAGE +FROM $BASE_IMAGE # Remove already existing rabbitmq mnesia directory files RUN sudo rm -rf /var/lib/rabbitmq/mnesia/* @@ -15,11 +15,12 @@ RUN if (. /etc/os-release && [ "$ID $VERSION_ID" = 'ubuntu 18.04' ]); then \ fi # Download the release tarball, start rabbitmq server and install the server +ARG VERSION RUN cd $(mktemp -d) \ - && wget https://www.zulip.org/dist/releases/zulip-server-{version}.tar.gz \ - && tar -xf zulip-server-{version}.tar.gz \ + && 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 + && 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/build-docker-images b/tools/ci/build-docker-images new file mode 100755 index 0000000000..944d20a19c --- /dev/null +++ b/tools/ci/build-docker-images @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -eux +cd "$(dirname "${BASH_SOURCE[0]}")" +docker build . --build-arg=BASE_IMAGE=buildpack-deps:bionic-scm --pull --tag=zulip/ci:bionic +docker build . --build-arg=BASE_IMAGE=buildpack-deps:focal-scm --pull --tag=zulip/ci:focal +docker build . --build-arg=BASE_IMAGE=buildpack-deps:buster-scm --pull --tag=zulip/ci:buster +docker build . --build-arg=BASE_IMAGE=buildpack-deps:bullseye-scm --pull --tag=zulip/ci:bullseye +docker build . -f Dockerfile.prod --build-arg=BASE_IMAGE=zulip/ci:buster --build-arg=VERSION=3.4 --tag=zulip/ci:buster-3.4 diff --git a/tools/ci/generate-dockerfiles b/tools/ci/generate-dockerfiles deleted file mode 100755 index bd674866e8..0000000000 --- a/tools/ci/generate-dockerfiles +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -import os - -import yaml - -if __name__ == "__main__": - os.chdir(os.path.abspath(os.path.dirname(__file__))) - - 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["distros"]: - dockerfile_path = f"images/{distro}/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.template - -""" - ) - 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 deleted file mode 100644 index b758494090..0000000000 --- a/tools/ci/images.yml +++ /dev/null @@ -1,16 +0,0 @@ -distros: - bionic: - base_image: buildpack-deps:bionic-scm - - focal: - base_image: buildpack-deps:focal-scm - - buster: - base_image: buildpack-deps:buster-scm - - bullseye: - base_image: buildpack-deps:bullseye-scm -servers: - buster-3.4: - base_image: zulip/ci:buster - version: 3.4