Skip to content

Conversation

@grayside
Copy link
Contributor

@grayside grayside commented Dec 7, 2018

Remove EXPOSE directive from all helloworld serving samples.

@steren indicated this was not required, so in the interest of simplicity lets remove it.

@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 7, 2018
FROM google/dart-runtime

# Configure and document the service HTTP port.
ENV PORT 8080
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

(true for all samples)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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:

  1. Having sensible defaults to ensure the container will work locally.
  2. Documenting what the PORT env var is about for practitioners that read the Dockerfile but not the docs.

Copy link
Contributor

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]

Copy link
Contributor Author

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?

Copy link
Contributor

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"

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Configure the service HTTP port.
# Set the default value for PORT environment variable.

Copy link
Contributor

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?

Copy link
Contributor

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.

@grayside grayside force-pushed the helloworld/remove-expose branch from 00bb321 to ee93f69 Compare January 3, 2019 19:27
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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 3, 2019
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@averikitsch
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 11, 2019
@averikitsch
Copy link
Contributor

/test pull-knative-docs-build-tests

@averikitsch
Copy link
Contributor

I0111 18:56:10.123] FILE: serving/samples/helloworld-dart/README.md
I0111 18:56:10.482] [✖] www.dartlang.org
I0111 18:56:10.482] 
I0111 18:56:10.483] ERROR: dead links found!
I0111 18:56:10.737] 
I0111 18:56:10.737] FILE: serving/samples/helloworld-elixir/README.md
I0111 18:56:11.025] [✖] http://localhost:4000
I0111 18:56:11.026] 
I0111 18:56:11.026] ERROR: dead links found!

Tests error at dead links; however they aren't dead.
@mattmoor @samodell any insight?

@samodell
Copy link
Contributor

It looks like our new build tests are a bit over-sensitive. @adrcunha

  1. Can we customize the checker so that it ignores links that point to http://localhost... ?
  2. I'm less sure why www.dartlang.org isn't recognized as a valid link. Does the checker require "http://"?

@adrcunha
Copy link
Contributor

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. :)

@adrcunha
Copy link
Contributor

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.

@averikitsch
Copy link
Contributor

/test pull-knative-docs-build-tests

@samodell
Copy link
Contributor

It looks like it's failing because of the merge conflicts. That test should pass once those are cleared up.

@samodell
Copy link
Contributor

@grayside Ping to resolve merge conflicts. This should be mergeable after that.

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2019
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jan 24, 2019
@averikitsch
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2019
@knative-prow-robot knative-prow-robot merged commit 921aa48 into knative:master Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/needs-eng-input Engineering input is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants