|
| 1 | +# Run scripts, commands, and actions as part of environment building |
| 2 | + |
| 3 | +In addition to installing using [standard configuration files](#config-files), you can run your own custom actions and commands as part of the build or user session launch process. |
| 4 | + |
| 5 | +(commands-jovyan)= |
| 6 | +## Commands are run as the `jovyan` user and not root |
| 7 | + |
| 8 | +Whenever you run a custom command, it is run as a special user called `jovyan`. |
| 9 | +It **does not have `root` privileges**. |
| 10 | +So, you should choose actions that do not require these privileges. |
| 11 | + |
| 12 | +For example, if you're using a `postBuild` script to install and use a new environment manager like [the `pixi` CLI](https://pixi.sh/latest/), make sure to install and configure it to a location accessible (and writable) to a user. For example: |
| 13 | + |
| 14 | +- ✅ `$CONDA_BIN` would work, because `conda` puts its binary folder in a user-accessible space. |
| 15 | +- ✅ `~/.local/bin` would work, because it's in the home directory. |
| 16 | +- ❌ `/usr/bin` would *NOT* work, because it requires root privileges to write to. |
| 17 | + |
| 18 | +## Run commands before finalizing your environment image |
| 19 | + |
| 20 | +You can run arbitrary commands before finalizing your environment image. |
| 21 | +This is useful in cases like: |
| 22 | + |
| 23 | +- You want to install and use custom environment management software that isn't supported by [repo2docker's configuration files](#config-files) (e.g., `pixi`). |
| 24 | +- You want to run custom commands to setup the environment properly (e.g., download a small dataset and put it in a specific location in the image). |
| 25 | + |
| 26 | +To do so, use a `postBuild` script, see [](#postbuild) for more information. |
| 27 | + |
| 28 | +## Run commands before launching a new user session |
| 29 | + |
| 30 | +You can run commands before launching a new **user session**. |
| 31 | +These are not baked into the environment image, they'll only be run once an image has been launched, but before the user's interactive session has been created. |
| 32 | + |
| 33 | +This is useful for things like: |
| 34 | + |
| 35 | +- Start a local server running that you want a user to have access to. |
| 36 | +- Updating a local dataset that always needs to have the latest information in it. |
| 37 | + |
| 38 | +To do so, use a `start` script. See [](#config-start) for more information. |
0 commit comments