Skip to content

Commit 384ea85

Browse files
brumikhimdel
andauthored
Added insights dev setup standalone (#1526)
* Update insights dev environment Issue: AAH-1262 * README: clean up insights mode docs, there is no insights-proxy or spandx anymore * drop profiles/ - unused now goes with ansible/galaxy_ng#1224 * add the basic config, frontend-components-config-utilities taken from #1526, except less changes * docker/entrypoint.sh - show an error when using ANSIBLE_HUB_UI_PATH in insights mode this would technically work as configured, except `npm run start` now involves running docker to start more container dockerd won't start in the existing alpine env, failing on missing cgroups v2 and there's no podman apk switching to bullseye based node container might still work though Co-authored-by: Martin Hradil <mhradil@redhat.com>
1 parent 74fa096 commit 384ea85

8 files changed

+49
-96
lines changed

CHANGES/1262.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update insights dev environment

README.md

+9-49
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,27 @@ This project can now be run as a container alongside the API. Just follow the in
1010

1111
## Develop without containers
1212

13-
This app can be developed in standalone mode or insights mode. Insights mode compiles the app to be run on the Red Hat cloud services platform (insights) and requires access to the Red Hat VPN as well as the insights proxy. Standalone mode only requires a running instance of the galaxy API for the UI to connect to.
13+
This app can be developed in standalone mode or insights mode. Insights mode compiles the app to be run on the Red Hat cloud services platform (insights). Standalone mode only requires a running instance of the galaxy API for the UI to connect to.
1414

1515
### Develop in Standalone Mode
1616

1717
1. Clone the [galaxy_ng](https://github.com/ansible/galaxy_ng) repo and follow the instructions for starting up the API.
18-
2. Install node. Node v13+ are known to work. Older versions may work as well.
18+
2. Install node. Node v14+ is known to work. Older versions may work as well.
1919
3. `npm install`
2020
4. `npm run start-standalone`
2121

22-
The app will run on http://localhost:8002 and proxy requests for `api/automation-hub` to the api on `http://localhost:5001`.
22+
The app will run on http://localhost:8002/ui and proxy requests for `/api/automation-hub` to the api on `http://localhost:5001`.
2323

2424
### Develop in Insights Mode
2525

26-
**NOTE:** This option is only available to Red Hat employees who have access to the Red Hat VPN. Community contributors should follow setup for [standalone mode](#develop-in-standalone-mode)
26+
**NOTE:** This option is only relevant to Red Hat employees. Community contributors should follow setup for [standalone mode](#develop-in-standalone-mode)
2727

28-
To enable insights mode set `DEPLOYMENT_MODE: 'insights'` in [custom.dev.config.js](./custom.dev.config.js).
29-
30-
This app is part of the Red Hat cloud platform. Because of that the app needs to be loaded within the context of console.redhat.com. This is done by accessing the app via the [insights-proxy project](https://github.com/RedHatInsights/insights-proxy).
31-
32-
#### Set up Insights Proxy
33-
34-
- Install docker
35-
- Clone this repo `git@github.com:RedHatInsights/insights-proxy.git` to your machine
36-
- Inside the `insights-proxy/` directory on your computer, run the following scripts
37-
- `npm install`
38-
- `bash scripts/update.sh` This updates the insights proxy container to the latest version.
39-
- `sudo bash scripts/patch-etc-hosts.sh` This adds the following entries to your `/etc/hosts` file
40-
41-
```
42-
127.0.0.1 prod.foo.redhat.com
43-
127.0.0.1 stage.foo.redhat.com
44-
127.0.0.1 qa.foo.redhat.com
45-
127.0.0.1 ci.foo.redhat.com
46-
```
47-
48-
Once all this is done, you can launch `insights-proxy` with this command:
49-
50-
```
51-
SPANDX_CONFIG=/path/to/ansible-hub-ui/profiles/local-frontend-and-api.js bash /path/to/insights-proxy/scripts/run.sh
52-
```
53-
54-
This should launch `insights-proxy`, which will redirect the routes defined in `profiles/local-frontend-and-api.js` to the automation hub UI running locally on your machine.
55-
56-
##### NOTE
57-
58-
If you are on a Mac, you might have to make a small change to the `insights-proxy/scripts/run.sh` script. Update this line
59-
60-
```
61-
REALPATH=`python2 -c 'import os,sys;print os.path.realpath(sys.argv[1])' $SPANDX_CONFIG`
62-
```
63-
64-
to use `python` instead of `python2`.
65-
66-
#### Run Automation Hub
67-
68-
Once the insights proxy is running, open a new terminal, navigate to your local copy of `ansible-hub-ui` and execute
69-
70-
1. `npm install`
71-
2. `npm run start`
28+
1. Clone the [galaxy_ng](https://github.com/ansible/galaxy_ng) repo and start the API with `COMPOSE_PROFILE=insights`.
29+
2. Install node. Node v14+ is known to work. Older versions may work as well.
30+
3. `npm install`
31+
4. `npm run start`
7232

73-
To access the app, visit: https://ci.foo.redhat.com:1337/insights/automation-hub
33+
The app will run on http://localhost:8002/beta/ansible/automation-hub and proxy requests for `/api/automation-hub` to the api on `http://localhost:5001`.
7434

7535
## Deploying
7636

config/insights.dev.webpack.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const webpackBase = require('./webpack.base.config');
22

3+
const proxyHost = process.env.API_PROXY_HOST || 'localhost';
4+
const proxyPort = process.env.API_PROXY_PORT || '5001';
5+
36
module.exports = webpackBase({
47
// The host where the API lives. EX: https://localhost:5001
58
API_HOST: '',
@@ -8,6 +11,9 @@ module.exports = webpackBase({
811
API_BASE_PATH: '/api/automation-hub/',
912
PULP_API_BASE_PATH: '/api/automation-hub/pulp/api/v3/',
1013

14+
// Value for standalone.api.target
15+
API_PROXY_TARGET: `http://${proxyHost}:${proxyPort}`,
16+
1117
// Path on the host where the UI is found. EX: /apps/automation-hub
1218
UI_BASE_PATH: '',
1319

@@ -29,7 +35,7 @@ module.exports = webpackBase({
2935
USE_FAVICON: false,
3036

3137
// Serve the UI over http or https. Options: true, false
32-
UI_USE_HTTPS: true,
38+
UI_USE_HTTPS: false,
3339

3440
// Enables webpack debug mode. Options: true, false
3541
UI_DEBUG: true,

config/webpack.base.config.js

+24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const { resolve } = require('path'); // node:path
22
const config = require('@redhat-cloud-services/frontend-components-config');
3+
const {
4+
rbac,
5+
defaultServices,
6+
} = require('@redhat-cloud-services/frontend-components-config-utilities/standalone');
37
const webpack = require('webpack');
48
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
59
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@@ -37,6 +41,7 @@ const defaultConfigs = [
3741
{ name: 'WEBPACK_PROXY', default: undefined, scope: 'webpack' },
3842
{ name: 'WEBPACK_PUBLIC_PATH', default: undefined, scope: 'webpack' },
3943
{ name: 'USE_FAVICON', default: true, scope: 'webpack' },
44+
{ name: 'API_PROXY_TARGET', default: undefined, scope: 'webpack' },
4045
];
4146

4247
module.exports = (inputConfigs) => {
@@ -86,6 +91,21 @@ module.exports = (inputConfigs) => {
8691

8792
// frontend-components-config 4.5.0+: don't remove patternfly from non-insights builds
8893
bundlePfModules: isStandalone,
94+
95+
// insights dev
96+
...(!isStandalone &&
97+
!isBuild && {
98+
appUrl: '/beta/ansible/automation-hub/',
99+
deployment: 'beta/apps',
100+
standalone: {
101+
api: {
102+
context: [customConfigs.API_BASE_PATH],
103+
target: customConfigs.API_PROXY_TARGET,
104+
},
105+
rbac,
106+
...defaultServices,
107+
},
108+
}),
89109
});
90110

91111
// Override sections of the webpack config to work with TypeScript
@@ -174,6 +194,10 @@ module.exports = (inputConfigs) => {
174194
isBuild ? '../src/app-entry.js' : '../src/dev-entry.js',
175195
),
176196
},
197+
...(!isBuild && {
198+
// fixes "Shared module is not available for eager consumption"
199+
exclude: ['@patternfly/react-core'],
200+
}),
177201
},
178202
),
179203
);

docker/entrypoint.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/bin/sh
22
if [[ $DEPLOYMENT_MODE == 'insights' ]]
33
then
4-
npm run start
4+
echo 1>&2
5+
echo 'ANSIBLE_HUB_UI_PATH not supported in insights mode' 1>&2
6+
echo 1>&2
7+
echo 'please run' 1>&2
8+
echo ' npm run start' 1>&2
9+
echo 'in the UI dir manually' 1>&2
10+
echo 1>&2
511
else
612
npm run start-standalone
713
fi

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@lingui/macro": "^3.13.3",
4646
"@ls-lint/ls-lint": "^1.11.0",
4747
"@redhat-cloud-services/frontend-components-config": "^4.6.6",
48+
"@redhat-cloud-services/frontend-components-config-utilities": "^1.5.17",
4849
"@typescript-eslint/eslint-plugin": "^5.21.0",
4950
"@typescript-eslint/parser": "^5.20.0",
5051
"babel-core": "^7.0.0-bridge.0",

profiles/galaxy-ng-compose.js

-25
This file was deleted.

profiles/local-frontend-and-api.js

-20
This file was deleted.

0 commit comments

Comments
 (0)