From 2d065a32ec3f2b695050c8e9eb91bb0721b2fcb5 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 8 May 2020 15:44:47 +0300 Subject: [PATCH] docs(docs-infra): improve docs on creating/updating the preview server Docker image (#37015) This commit includes the following improvements: - Document that the `create-image.sh` script (and by extention the `update-preview-server.sh` script) need to have access to a `yarn` executable. - Add a note on cron jobs running in non-interactive, non-login shells (which affects their execution context and have different behavior vs running the same commands in an interactive, login shell). - Change the Node.js and `yarn` installation instructions to ensure the `yarn` executable will be available on the `PATH` and not require an interactive, login shell (as happens, for example, when installing it via [nvm](https://github.com/nvm-sh/nvm)). This makes it easier to set up a cron job that runs the `update-preview-server.sh` script. NOTE: The equivalent updates have been made on the GCE VM that hosts the PR preview server. PR Close #37015 --- .../docs/vm-setup--create-docker-image.md | 11 +++++++---- .../docs/vm-setup--update-docker-container.md | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/aio/aio-builds-setup/docs/vm-setup--create-docker-image.md b/aio/aio-builds-setup/docs/vm-setup--create-docker-image.md index 935a77c27f..7b77859672 100644 --- a/aio/aio-builds-setup/docs/vm-setup--create-docker-image.md +++ b/aio/aio-builds-setup/docs/vm-setup--create-docker-image.md @@ -4,9 +4,8 @@ ## Install git, Node.js and yarn - `sudo apt-get update` - `sudo apt-get install -y git` -- Install [nvm](https://github.com/nvm-sh/nvm#installing-and-updating). -- Install Node.js: `nvm install 12` -- Install yarn: `npm install --global yarn` +- Install the latest stable version of [Node.js](https://nodejs.org/en/download). +- Install the latest stable version of [yarn](https://classic.yarnpkg.com/en/docs/install). ## Checkout repository @@ -18,7 +17,11 @@ - You can overwrite the default environment variables inside the image, by passing new values using `--build-arg`. -**Note:** The script has to execute docker commands with `sudo`. +**Note 1:** The script has to execute docker commands with `sudo`. + +**Note 2:** +The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the +script. ## Example diff --git a/aio/aio-builds-setup/docs/vm-setup--update-docker-container.md b/aio/aio-builds-setup/docs/vm-setup--update-docker-container.md index 3347e6930c..e62dbb354f 100644 --- a/aio/aio-builds-setup/docs/vm-setup--update-docker-container.md +++ b/aio/aio-builds-setup/docs/vm-setup--update-docker-container.md @@ -8,7 +8,7 @@ VM host to update the preview server based on changes in the source code. The script will pull the latest changes from the origin's master branch and examine if there have been any changes in files inside the preview server source code directory (see below). If there are, -it will create a new image and verify that is works as expected. Finally, it will stop and remove +it will create a new image and verify that it works as expected. Finally, it will stop and remove the old docker container and image, create a new container based on the new image and start it. The script assumes that the preview server source code is in the repository's @@ -25,7 +25,11 @@ used for. **Note 1:** The script has to execute docker commands with `sudo`. -**Note 2:** Make sure the user that executes the script has access to update the repository +**Note 2:** +The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the +script. + +**Note 3:** Make sure the user that executes the script has access to update the repository. ## Run the script manually @@ -50,3 +54,9 @@ log its output to `update-preview-server.log` (assuming the user has the necessa # Periodically check for changes and update the preview server (if necessary) */30 * * * * /path/to/update-preview-server.sh /path/to/repo /path/to/secrets /path/to/builds /path/to/localcerts /path/to/logs >> /path/to/update-preview-server.log 2>&1 ``` + +**Note:** +Keep in mind that cron jobs run in non-interactive, non-login shells. This means that the execution +context might be different compared to when running the same commands from an interactive, login +shell. For example, `.bashrc` files are normally _not_ sourced automatically in cron jobs. See +[here](http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html) for more info.