The root directory and its package.json
file serves as an entry point for any
interactions with the applications and packages.
If you are developing only StackRox UI, then you don't have to install all the build tooling described in the parent README.md. Instead, follow the instructions below.
- Docker
- Node.js version compatible with the
"engine"
requirements in the package.json file (It's highly recommended to use the latest LTS version. If you're managing multiple versions of Node.js on your machine, consider using nvm) - npm v9.x
Before starting, make sure you have the above tools installed on your machine
and you've run npm ci
in the apps/platform
directory to download dependencies.
The front end development environment consists of a CRA-provided dev server to serve static UI assets and deployed StackRox Docker containers that provide backend API.
Set up your environment as follows:
Note: Similar instructions apply when using Minikube.
-
Docker for Mac - Make sure you have Kubernetes enabled in your Docker for Mac and
kubectl
is pointing todocker-desktop
(see docker docs). Note that Docker for Mac is no longer the most recommended k8s environment for development. Some recommended alternatives arepodman-desktop
orcolima
. -
Deploy - Run
npm run deploy-local
(wraps../deploy/k8s/deploy-local.sh
) to deploy the StackRox k8s app. Make sure that your git working directory is clean and that the branch that you're on has a corresponding tag from CI (see Roxbot comment for a PR branch). Alternatively, you can specify the image tag you want to deploy by setting theMAIN_IMAGE_TAG
env var. Ifnpm run deploy-local
fails, see this Knowledge Base article for debugging instructions. -
Start - Start your local dev server by running
npm run start
. This will build the application in watch mode. To see available options tonpm run start
, first ensure thatnpm run build
has been run from the top level and then refer to the README.md in theapps/platform
directory.
Note: to redeploy a newer version of StackRox, delete existing app using
teardown
script from the workflow
repo, and repeat the steps above.
To develop the front-end platform locally, but use a remote Central, please refer to the detailed instructions in the how-to article Use remote Central for local front-end dev
This project is IDE agnostic. For the best dev experience, it's recommended to add / configure support for ESLint and Prettier in the IDE of your choice.
Examples of configuration for some IDEs:
- Visual Studio Code: Install plugins
ESLint
and
Prettier,
then add configuration to
settings.json
:
"eslint.alwaysShowStatus": true,
"eslint.codeAction.showDocumentation": {
"enable": true
},
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
- IntelliJ IDEA /
WebStorm /
GoLand: Install and configure
ESLint plugin. To apply
autofixes on file save add
File Watcher
to watch JavaScript files and to run ESLint program
rox/ui/node_modules/.bin/eslint
with arguments--fix $FilePath$
.
For better development experience it's recommended to use Google Chrome Browser with the following extensions installed: