From 2476e3fa2572a726d92022b0ec9be46af8166567 Mon Sep 17 00:00:00 2001 From: Iain Billett Date: Mon, 5 Oct 2020 16:55:34 +0100 Subject: [PATCH] Add Dockerfile for helm chart Add a Dockerfile which can be used to build an image that the helm charts will use as default. These images require mkdocs and cookiecutter to be installed (for now) in order to work around the docker requirement in kubernetes. --- .../kubernetes-example-backend/Dockerfile | 35 +++++++++++++++++++ .../kubernetes-example-backend/README.md | 13 +++++++ 2 files changed, 48 insertions(+) create mode 100644 contrib/docker/kubernetes-example-backend/Dockerfile create mode 100644 contrib/docker/kubernetes-example-backend/README.md diff --git a/contrib/docker/kubernetes-example-backend/Dockerfile b/contrib/docker/kubernetes-example-backend/Dockerfile new file mode 100644 index 0000000000..df617decf5 --- /dev/null +++ b/contrib/docker/kubernetes-example-backend/Dockerfile @@ -0,0 +1,35 @@ +FROM node:12-buster + +WORKDIR /usr/src/app + +# (workaround) Install cookiecutter and mkdocs to avoid the need to run docker in docker +RUN cd /tmp && curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz && \ + tar -xvf Python-3.8.2.tar.xz && \ + cd Python-3.8.2 && \ + ./configure --enable-optimizations && \ + make -j 4 && \ + make altinstall + +RUN apt update +RUN apt install -y mkdocs + +RUN pip3.8 install mkdocs-techdocs-core + +RUN pip3.8 install cookiecutter && \ + apt remove -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev libbz2-dev g++ python-pip python-dev && \ + rm -rf /var/cache/apt/* /tmp/Python-3.8.2 + +# Copy repo skeleton first, to avoid unnecessary docker cache invalidation. +# The skeleton contains the package.json of each package in the monorepo, +# and along with yarn.lock and the root package.json, that's enough to run yarn install. +ADD yarn.lock package.json skeleton.tar ./ + +RUN yarn install --frozen-lockfile --production + +# This will copy the contents of the dist-workspace when running the build-image command. +# Do not use this Dockerfile outside of that command, as it will copy in the source code instead. +COPY . . + +CMD ["node", "packages/backend"] + + diff --git a/contrib/docker/kubernetes-example-backend/README.md b/contrib/docker/kubernetes-example-backend/README.md new file mode 100644 index 0000000000..d0f9d57022 --- /dev/null +++ b/contrib/docker/kubernetes-example-backend/README.md @@ -0,0 +1,13 @@ +# Example backend Dockerfile + +This Dockerfile will build the example backend with certain additional binaries needed to workaround +the docker requirement in the scaffolder and techdocs. + +# Usage + +```bash +yarn docker-build -f --tag +``` + +> The absolute path is necessary as this directory is not copied to the build workspace when building +> the docker image.