Skip to content

Commit 3f70e3d

Browse files
gkalpakkara
authored andcommitted
docs(docs-infra): improve docs on creating/updating the preview server Docker image (angular#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 angular#37015
1 parent 0b68189 commit 3f70e3d

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

aio/aio-builds-setup/docs/vm-setup--create-docker-image.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
## Install git, Node.js and yarn
55
- `sudo apt-get update`
66
- `sudo apt-get install -y git`
7-
- Install [nvm](https://github.com/nvm-sh/nvm#installing-and-updating).
8-
- Install Node.js: `nvm install 12`
9-
- Install yarn: `npm install --global yarn`
7+
- Install the latest stable version of [Node.js](https://nodejs.org/en/download).
8+
- Install the latest stable version of [yarn](https://classic.yarnpkg.com/en/docs/install).
109

1110

1211
## Checkout repository
@@ -18,7 +17,11 @@
1817
- You can overwrite the default environment variables inside the image, by passing new values using
1918
`--build-arg`.
2019

21-
**Note:** The script has to execute docker commands with `sudo`.
20+
**Note 1:** The script has to execute docker commands with `sudo`.
21+
22+
**Note 2:**
23+
The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the
24+
script.
2225

2326

2427
## Example

aio/aio-builds-setup/docs/vm-setup--update-docker-container.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ VM host to update the preview server based on changes in the source code.
88

99
The script will pull the latest changes from the origin's master branch and examine if there have
1010
been any changes in files inside the preview server source code directory (see below). If there are,
11-
it will create a new image and verify that is works as expected. Finally, it will stop and remove
11+
it will create a new image and verify that it works as expected. Finally, it will stop and remove
1212
the old docker container and image, create a new container based on the new image and start it.
1313

1414
The script assumes that the preview server source code is in the repository's
@@ -25,7 +25,11 @@ used for.
2525

2626
**Note 1:** The script has to execute docker commands with `sudo`.
2727

28-
**Note 2:** Make sure the user that executes the script has access to update the repository
28+
**Note 2:**
29+
The script has to execute `yarn` commands, so make sure `yarn` is on the `PATH` when invoking the
30+
script.
31+
32+
**Note 3:** Make sure the user that executes the script has access to update the repository.
2933

3034

3135
## Run the script manually
@@ -50,3 +54,9 @@ log its output to `update-preview-server.log` (assuming the user has the necessa
5054
# Periodically check for changes and update the preview server (if necessary)
5155
*/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
5256
```
57+
58+
**Note:**
59+
Keep in mind that cron jobs run in non-interactive, non-login shells. This means that the execution
60+
context might be different compared to when running the same commands from an interactive, login
61+
shell. For example, `.bashrc` files are normally _not_ sourced automatically in cron jobs. See
62+
[here](http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html) for more info.

0 commit comments

Comments
 (0)