From 7c635c23e8daa30e3a974c1f2053bf5c2339cfd8 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 31 Oct 2018 22:56:28 +0100 Subject: [PATCH 1/2] Add a docker file for building frontend assets --- docker/frontend.dockerfile | 38 ++++++++++++++++++++++++++++++++++ docs/development/standards.rst | 23 ++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 docker/frontend.dockerfile diff --git a/docker/frontend.dockerfile b/docker/frontend.dockerfile new file mode 100644 index 00000000000..8134f959731 --- /dev/null +++ b/docker/frontend.dockerfile @@ -0,0 +1,38 @@ +FROM ubuntu:bionic + +ENV LANG C.UTF-8 + +# install latest python and nodejs +RUN apt-get update && \ + apt-get install -y \ + nodejs \ + npm \ + gettext \ + git \ + sudo \ + build-essential \ + python3 \ + python3-dev \ + python3-pip \ + libxml2-dev \ + libxslt1-dev \ + zlib1g-dev + +RUN bash -c "pip3 install pip setuptools --upgrade --force-reinstall" +RUN bash -c "pip3 install virtualenv" +RUN bash -c "npm install -g bower" + +# RUN adduser --system --shell /bin/bash --home "/repo" rtd + +# A volume used to share `pex`/`whl` files and fixtures with docker host +VOLUME /repo + +# do the time-consuming base install commands +CMD /bin/bash -c "/usr/local/bin/virtualenv -p python3 rtd \ + && source rtd/bin/activate \ + && cd /repo \ + && pip install -r requirements.txt \ + && npm install \ + && bower --allow-root install \ + && npm run vendor \ + && npm run build" diff --git a/docs/development/standards.rst b/docs/development/standards.rst index 2d8ab3cb3ae..3083951080d 100644 --- a/docs/development/standards.rst +++ b/docs/development/standards.rst @@ -53,8 +53,27 @@ may change, so that assets are compiled before deployment, however as our front end assets are in a state of flux, it's easier to keep absolute sources checked in. -Getting Started ---------------- +Containerized build (Docker) +---------------------------- + +Front end assets can be built in a Docker container. This reduces the steps +required and can be considered more secure, since you won't expose your local +development environment to packages from NPM. + +You will need to install Docker on your system, then run the following commands +from the root of your repository: + +.. code-block:: console + + # Builds the Docker image + docker image build . -t "rtd-frontend" -f docker/frontend.dockerfile + + # Runs the image from the repository root + docker run -v $PWD/:/repo "rtd-frontend" + + +Local build: Getting Started +---------------------------- You will need a working version of Node and NPM to get started. We won't cover that here, as it varies from platform to platform. From 34f0101dae6602121b8bd6a0af78d9e60d396fa2 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 20 May 2019 12:54:32 +0200 Subject: [PATCH 2/2] Modify header structure CC: @agjohnson --- docs/development/standards.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/development/standards.rst b/docs/development/standards.rst index 3083951080d..bc47f9f2758 100644 --- a/docs/development/standards.rst +++ b/docs/development/standards.rst @@ -53,8 +53,16 @@ may change, so that assets are compiled before deployment, however as our front end assets are in a state of flux, it's easier to keep absolute sources checked in. + +Getting Started +--------------- + +We describe two different ways of building front end assets: Either in a +containerized environment (Docker) or step-by-step in your local development +environment. + Containerized build (Docker) ----------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Front end assets can be built in a Docker container. This reduces the steps required and can be considered more secure, since you won't expose your local @@ -72,8 +80,8 @@ from the root of your repository: docker run -v $PWD/:/repo "rtd-frontend" -Local build: Getting Started ----------------------------- +Local builds +~~~~~~~~~~~~ You will need a working version of Node and NPM to get started. We won't cover that here, as it varies from platform to platform.