-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
wp-env: Add custom port numbers to .wp-env.json #20158
Conversation
This should support arbitrary environment variables and you should also be
able to scope them to a specific container.
|
Neat idea! Possible API: {
"plugins": [ "." ],
"environment": {
"mysql": {
"MYSQL_ALLOW_EMPTY_PASSWORD": "no"
},
"wordpress": {
"WP_ENV_PORT": "12345"
}
}
} Then we could spread the environment variables into each of the docker services. return {
version: '3.7',
services: {
mysql: {
image: 'mariadb',
environment: {
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes',
...( config.environment.mysql || { } ),
},
},
},
}; |
That looks sensible to me but don’t forget global ones. |
Per global ones, do you mean shell? i.e. have a way to specify:
In that case, we could have two different options:
The |
Yes, and the shell variables could also be forwarded to all containers as a
way of setting them for all containers at once.
|
Apologies in advance, I have opinions! 😅 Environment variables Is being able to customise environment variables in this way useful? Beyond I fear that this would detract from a key part of Moreover, Customising the port There are three places where configuration for
I'd argue that the port setting fits most neatly into (1). This aligns with the design of My ideal API for this would be that the port is specified in
|
Co-Authored-By: Robert Anderson <robert@noisysocks.com>
Thanks for the suggestions @noisysocks, everything should be fixed now. I also added some tests to cover the port number validation. I do agree with @epiqueras that adding environment variable support would be very powerful, but I also agree with @noisysocks take not having it keeps the tool simpler. At any rate, we could implement that in follow up if we really want it, and still have things like port numbers available through So with that, I think this PR is ready to go. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Let's update packages/env/CHANGELOG.md
to note this new functionality and then I think we're good to go.
Co-Authored-By: Robert Anderson <robert@noisysocks.com>
@noisysocks Added. Do I need to bump the package.json version as well? |
No, that's done when packages are next published. |
55f5650
to
c9c2f21
Compare
Thanks for the review, @noisysocks! I think it's wise to go with this and revisit more variable support later if/when the need arises. |
Allows the user to set `port` and `testsPort` in .wp-env.json. - Port must be a number - Ports must be different - Ports can still be overridden with the environment variables
Allows the user to set `port` and `testsPort` in .wp-env.json. - Port must be a number - Ports must be different - Ports can still be overridden with the environment variables
Description
This PR adds support for custom port numbers in the .wp-env.json file.
Here's why I like having this option:
wp-env start
with the port numbers if you need them to be different every timeThis does not change the behavior of the environment variables; they still take precedent over values in .wp-env.json. The default port numbers also stay the same.
How has this been tested?
I ran this code on my local plugin and verified that:
Checklist: