-
Notifications
You must be signed in to change notification settings - Fork 1.3k
serving/samples: remove EXPOSE directive from helloworld #644
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
serving/samples: remove EXPOSE directive from helloworld #644
Conversation
| FROM google/dart-runtime | ||
|
|
||
| # Configure and document the service HTTP port. | ||
| ENV PORT 8080 |
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.
You should remove PORT, this is injected by Knative.
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.
(true for all samples)
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.
I prefer to keep the explicit default as a way of documenting the contract and making it obvious how to override the port for experimentation.
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.
8080 is not part of the runtime contract, only PORT is: https://github.com/knative/serving/blob/master/docs/runtime-contract.md#process
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.
Explicitly showing this remains valuable, even if the value is a common convention rather than an official default.
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.
Just to make sure we have the same definition here, the ENV directive is a way to set a default environment variable value at build time which is overridden at run time by any mechanism which injects environment variables into the container.
I see including this line as a way of:
- Having sensible defaults to ensure the container will work locally.
- Documenting what the PORT env var is about for practitioners that read the Dockerfile but not the docs.
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.
My concerns is that users will assume these are the default values of PORT.
As far as I understand, the ENV directive is not needed for running locally when using docker -p.
Running locally is better done using $ PORT=8080 docker run -p 8080:${PORT} -e PORT=${PORT} [IMAGE]
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.
This is setting a default value for the service, which is a good practice. It also allows the container to be spun up with a more typical and abbreviated command:
docker run -p 8080 [IMAGE]
A good amount of the value in this is if developers take the Dockerfile and pivot to using this as part of an ongoing service.
The Day 1 value is in surfacing a bit of the runtime contract for developers that look at code first. What if a comment were added indicating that 8080 is not a requirement but a sane default?
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.
OK to leave ENV PORT 8080 in the Dockerfiles, but indeed please change the comment, "Configure the service HTTP port." is not correct. The service HTTP port is not configured via this env var. Use something like "Service must listen on $PORT, set value for local development"
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.
# Service must listen to $PORT environment variable.
# This default value facilitates local development.
| RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar | ||
|
|
||
| # Configure and document the service HTTP port. | ||
| # Configure the service HTTP port. |
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.
| # Configure the service HTTP port. | |
| # Set the default value for PORT environment variable. |
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.
Should this change be consistent across all the samples?
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.
Correct, just trying to figure out the phrasing.
00bb321 to
ee93f69
Compare
| RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar | ||
| # Configure and document the service HTTP port. | ||
| # Configure the service HTTP port. |
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.
Can you update the ReadMes as well?
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.
Working on it. This seems like a good spot for automation.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: averikitsch, grayside The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
/test pull-knative-docs-build-tests |
Tests error at dead links; however they aren't dead. |
|
It looks like our new build tests are a bit over-sensitive. @adrcunha
|
|
Probably the checker doesn't like an address without protocol, and I'm pretty sure localhost:4000 is not returning content at the time of checking. :) |
|
Actually the checker is correct: you must add the protocol to the darlang.org link, otherwise it will be treated as a "local" file. Just try clicking it in the README file and you'll see a nice 404 GitHub page. |
|
/test pull-knative-docs-build-tests |
|
It looks like it's failing because of the merge conflicts. That test should pass once those are cleared up. |
|
@grayside Ping to resolve merge conflicts. This should be mergeable after that. |
|
/lgtm |
Remove EXPOSE directive from all helloworld serving samples.
@steren indicated this was not required, so in the interest of simplicity lets remove it.