Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config to run addons-frontend with addons-server locally #9956

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ Here are some commands you can run:

| Command | Description |
| --- | --- |
| yarn amo | Start the dev server/proxy (for amo) using data from Docker. _This is not currently working. See [issue-7196][]_. |
| yarn amo:olympia | Start the dev server/proxy (for amo) using data from a local addons-server environment. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth adding a note that the site will be located at http://olympia.test:4000? I know that is output to the console, so maybe not necessary, but it could be helpful for folks expecting it to be the same location as with amo:dev and amo:stage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is it http://olympia.test:4000 or http://olympia.test:3333? Both seem to work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:3333 is the app, which runs behind the proxy at :4000.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the output is fine. We don't develop with both local envs in parallel usually so I think it's for power users who would read the console output :)

| yarn amo:dev | Start the dev server/proxy (for amo) using data from the dev server (https://addons-dev.allizom.org/) |
| yarn amo:dev-https | Same as `amo:dev` but with HTTPS, available at: https://example.com:3000/. [Read about setting up this environment](docs/moz-addon-manager.md#developing-with-a-local-https-server-recommended) |
| yarn amo:no-proxy | Start the dev server without a proxy (for amo) using data from Docker |
| yarn amo:stage | Start the dev server/proxy (for amo) using data from the staging server (https://addons.allizom.org/) |
| yarn build | Build the app. |
| yarn build-ci | Run the `build` and `bundlesize` npm scripts. |
Expand Down Expand Up @@ -388,6 +387,5 @@ curl https://addons-dev.allizom.org/__version__
- Unit tests with high coverage (aiming for 100%)

[bundlesize]: https://github.com/siddharthkp/bundlesize
[issue-7196]: https://github.com/mozilla/addons-frontend/issues/7196
[jest]: https://jestjs.io/docs/en/getting-started.html
[prettier]: https://prettier.io/
11 changes: 6 additions & 5 deletions bin/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const useHttpsForDev = process.env.USE_HTTPS_FOR_DEV;
const protocol = useHttpsForDev ? 'https' : 'http';

const apiHost = config.get('proxyApiHost', null) || config.get('apiHost');
const frontendHost = `${protocol}://${config.get('serverHost')}:${config.get('serverPort')}`;
const serverHost = config.get('serverHost');
const serverPort = parseInt(config.get('serverPort'), 10);
const frontendHost = `${protocol}://${serverHost}:${serverPort}`;

log.info(`apiHost: ${apiHost}`);
log.info(`frontendHost: ${frontendHost}`);
Expand Down Expand Up @@ -93,8 +95,7 @@ proxy.on('error', (error, req, res) => {
res.end(htmlFile);
});

const host = useHttpsForDev ? process.env.SERVER_HOST : 'localhost';
const port = parseInt(config.get('proxyPort', '3333'), 10);
const proxyPort = parseInt(config.get('proxyPort'), 10);

log.info(`🚦 Proxy running at ${protocol}://${host}:${port}`);
server.listen(port);
log.info(`🚦 Proxy running at ${protocol}://${serverHost}:${proxyPort}`);
server.listen(proxyPort);
15 changes: 15 additions & 0 deletions config/development-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This config should be used with a local addons-server setup.
module.exports = {
apiHost: 'http://olympia.test',
proxyPort: 4000,

serverHost: 'olympia.test',

baseURL: 'http://olympia.test',

webpackServerPort: 4001,

mozillaUserId: 10968,
CSP: false,
enableNodeStatics: true,
};
2 changes: 1 addition & 1 deletion config/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {

enableStrictMode: true,

serverPort: 3000,
serverPort: 3333,
webpackServerHost,
webpackServerPort,
webpackHost,
Expand Down
20 changes: 0 additions & 20 deletions config/uitests.js

This file was deleted.

27 changes: 8 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"bundlesize": "bundlesize",
"extract-locales": "better-npm-run extract-locales",
"clean": "rimraf './dist/*!(.gitkeep)' './webpack-assets.json' './src/locale/**(!.gitkeep)'",
"amo": "better-npm-run amo",
"amo:dev": "better-npm-run amo:dev",
"amo:dev-https": "better-npm-run amo:dev-https",
"amo:ui-tests": "better-npm-run amo:ui-tests",
"amo:no-proxy": "better-npm-run amo:no-proxy",
"amo:olympia": "better-npm-run amo:olympia",
"amo:stage": "better-npm-run amo:stage",
"amo:ui-tests": "npm run amo:olympia",
"eslint": "eslint .",
"flow": "flow",
"flow:check": "flow check",
Expand Down Expand Up @@ -52,8 +51,11 @@
"NODE_PATH": "./:./src"
}
},
"amo": {
"command": "better-npm-run start-dev-proxy"
"amo:olympia": {
"command": "better-npm-run start-dev-proxy",
"env": {
"NODE_APP_INSTANCE": "local"
}
},
"amo:dev": {
"command": "better-npm-run start-dev-proxy",
Expand All @@ -71,18 +73,6 @@
"WEBPACK_SERVER_HOST": "example.com"
}
},
"amo:ui-tests": {
"command": "better-npm-run start-dev-proxy",
"env": {
"NODE_ENV": "production"
}
},
"amo:no-proxy": {
"command": "better-npm-run start-dev",
"env": {
"PROXY_ENABLED": "false"
}
},
"amo:stage": {
"command": "better-npm-run start-dev-proxy",
"env": {
Expand Down Expand Up @@ -115,8 +105,7 @@
"ENABLE_PIPING": "true",
"NODE_ENV": "development",
"NODE_ICU_DATA": "./node_modules/full-icu",
"NODE_PATH": "./:./src",
"SERVER_PORT": "3333"
"NODE_PATH": "./:./src"
}
},
"node": {
Expand Down