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

Config alternative for setting ports #29

Closed
joemaller opened this issue Aug 13, 2021 · 2 comments
Closed

Config alternative for setting ports #29

joemaller opened this issue Aug 13, 2021 · 2 comments
Assignees

Comments

@joemaller
Copy link
Member

https://github.com/ideasonpurpose/docker-wordpress-dev/blob/master/README.md#alternate-devserver-ports

This broke in npm v7, based on RFC 21

Alternate DevServer Ports

Webpack devserver runs on port 8080 by default. Multiple projects can be run simultaneously by using npm config to assign different ports the the project's package.json name. For example, three projects named csr-site, pro-bono and ar-project could be run simultaneously on custom ports, after running these commands:

npm config set csr-site:port 8080
npm config set pro-bono:port 8081
npm config set ar-project:port 8082

See also:

@joemaller joemaller self-assigned this Aug 13, 2021
joemaller added a commit that referenced this issue Aug 13, 2021
@joemaller
Copy link
Member Author

Could this be an argument to the tools invocation? npm run start would default to port 8080, npm run start 8081 would run on port 8081. Is it possible to pass a command line arg into an npm script? Difficult? The start script is just a wrapper for an ugly docker compose command.

@joemaller
Copy link
Member Author

Yes! Going with npm run start --port=8531 which would set the environment variable $npm_config_port to 8531. The docker compose files recognize this variable and pass it through.

Invocation scripts now call docker compose with --service-ports. This lets us define ports in docker-compose.json and to keep the package.json scripts a little cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant