Skip to content

Commit 921aa48

Browse files
graysideknative-prow-robot
authored andcommitted
serving/samples: remove EXPOSE directive from helloworld (#644)
* serving/samples: remove EXPOSE directive from helloworld * serving/samples: update ENV PORT comment for clarified purpose * serving/samples: update README for Dockerfile changes
1 parent 8b2eba4 commit 921aa48

File tree

28 files changed

+256
-245
lines changed

28 files changed

+256
-245
lines changed

serving/samples/helloworld-clojure/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ COPY . .
1313
# Build an uberjar release artifact.
1414
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
1515

16-
# Configure and document the service HTTP port.
16+
# Service must listen to $PORT environment variable.
17+
# This default value facilitates local development.
1718
ENV PORT 8080
18-
EXPOSE $PORT
1919

2020
# Run the web service on container startup.
2121
CMD ["java", "-jar", "app-standalone.jar"]

serving/samples/helloworld-clojure/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,29 @@ recreate the source files from this folder.
5959
see
6060
[the clojure image documentation](https://github.com/docker-library/docs/tree/master/clojure).
6161

62-
```docker
63-
# Use the official Clojure image.
64-
# https://hub.docker.com/_/clojure
65-
FROM clojure
62+
```docker
63+
# Use the official Clojure image.
64+
# https://hub.docker.com/_/clojure
65+
FROM clojure
6666
67-
# Create the project and download dependencies.
68-
WORKDIR /usr/src/app
69-
COPY project.clj .
70-
RUN lein deps
67+
# Create the project and download dependencies.
68+
WORKDIR /usr/src/app
69+
COPY project.clj .
70+
RUN lein deps
7171
72-
# Copy local code to the container image.
73-
COPY . .
72+
# Copy local code to the container image.
73+
COPY . .
7474
75-
# Build an uberjar release artifact.
76-
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
75+
# Build an uberjar release artifact.
76+
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
7777
78-
# Configure and document the service HTTP port.
79-
ENV PORT 8080
80-
EXPOSE $PORT
78+
# Service must listen to $PORT environment variable.
79+
# This default value facilitates local development.
80+
ENV PORT 8080
8181
82-
# Run the web service on container startup.
83-
CMD ["java", "-jar", "app-standalone.jar"]
84-
```
82+
# Run the web service on container startup.
83+
CMD ["java", "-jar", "app-standalone.jar"]
84+
```
8585
8686
1. Create a new file, `service.yaml` and copy the following service definition
8787
into the file. Make sure to replace `{username}` with your Docker Hub

serving/samples/helloworld-csharp/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ COPY . .
1414
# Build a release artifact.
1515
RUN dotnet publish -c Release -o out
1616

17-
# Configure and document the service HTTP port.
17+
# Service must listen to $PORT environment variable.
18+
# This default value facilitates local development.
1819
ENV PORT 8080
19-
EXPOSE $PORT
2020

2121
# Run the web service on container startup.
2222
CMD ["dotnet", "out/helloworld-csharp.dll"]

serving/samples/helloworld-csharp/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,30 @@ recreate the source files from this folder.
5555
app, see
5656
[dockerizing a .NET core app](https://docs.microsoft.com/en-us/dotnet/core/docker/docker-basics-dotnet-core#dockerize-the-net-core-application).
5757

58-
```docker
59-
# Use Microsoft's official .NET image.
60-
# https://hub.docker.com/r/microsoft/dotnet
61-
FROM microsoft/dotnet:2.1-sdk
62-
63-
# Install production dependencies.
64-
# Copy csproj and restore as distinct layers.
65-
WORKDIR /app
66-
COPY *.csproj .
67-
RUN dotnet restore
68-
69-
# Copy local code to the container image.
70-
COPY . .
71-
72-
# Build a release artifact.
73-
RUN dotnet publish -c Release -o out
74-
75-
# Configure and document the service HTTP port.
76-
ENV PORT 8080
77-
EXPOSE $PORT
78-
79-
# Run the web service on container startup.
80-
CMD ["dotnet", "out/helloworld-csharp.dll"]
81-
```
58+
```docker
59+
# Use Microsoft's official .NET image.
60+
# https://hub.docker.com/r/microsoft/dotnet
61+
FROM microsoft/dotnet:2.1-sdk
62+
63+
# Install production dependencies.
64+
# Copy csproj and restore as distinct layers.
65+
WORKDIR /app
66+
COPY *.csproj .
67+
RUN dotnet restore
68+
69+
# Copy local code to the container image.
70+
COPY . .
71+
72+
# Build a release artifact.
73+
RUN dotnet publish -c Release -o out
74+
75+
# Service must listen to $PORT environment variable.
76+
# This default value facilitates local development.
77+
ENV PORT 8080
78+
79+
# Run the web service on container startup.
80+
CMD ["dotnet", "out/helloworld-csharp.dll"]
81+
```
8282
8383
1. Create a new file, `service.yaml` and copy the following service definition
8484
into the file. Make sure to replace `{username}` with your Docker Hub

serving/samples/helloworld-dart/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# https://hub.docker.com/r/google/dart-runtime/
33
FROM google/dart-runtime
44

5-
# Configure and document the service HTTP port.
5+
# Service must listen to $PORT environment variable.
6+
# This default value facilitates local development.
67
ENV PORT 8080
7-
EXPOSE $PORT

serving/samples/helloworld-dart/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ be created using the following instructions.
7171
4. Create a new file named `Dockerfile`, this file defines instructions for
7272
dockerizing your applications, for dart apps this can be done as follows:
7373

74-
```Dockerfile
75-
# Use Google's official Dart image.
76-
# https://hub.docker.com/r/google/dart-runtime/
77-
FROM google/dart-runtime
78-
79-
# Configure and document the service HTTP port.
80-
ENV PORT 8080
81-
EXPOSE $PORT
82-
```
74+
```Dockerfile
75+
# Use Google's official Dart image.
76+
# https://hub.docker.com/r/google/dart-runtime/
77+
FROM google/dart-runtime
78+
79+
# Service must listen to $PORT environment variable.
80+
# This default value facilitates local development.
81+
ENV PORT 8080
82+
```
8383

8484
5. Create a new file, `service.yaml` and copy the following service definition
8585
into the file. Make sure to replace `{username}` with your Docker Hub

serving/samples/helloworld-elixir/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ USER appuser
3333

3434
ENV PORT=8080 MIX_ENV=prod REPLACE_OS_VARS=true
3535
WORKDIR /opt/app
36-
EXPOSE 8080
3736
COPY --from=0 /opt/release .
3837
ENV RUNNER_LOG_DIR /var/log
3938
CMD ["/opt/app/bin/start_server", "foreground", "boot_var=/tmp"]

serving/samples/helloworld-elixir/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ When asked, if you want to `Fetch and install dependencies? [Yn]` select `y`
8484
# Document that the service listens on port 8080.
8585
ENV PORT=8080 MIX_ENV=prod REPLACE_OS_VARS=true
8686
WORKDIR /opt/app
87-
EXPOSE 8080
8887
COPY --from=0 /opt/release .
8988
ENV RUNNER_LOG_DIR /var/log
9089

serving/samples/helloworld-go/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ FROM alpine
1919
# Copy the binary to the production image from the builder stage.
2020
COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld
2121

22-
# Configure and document the service HTTP port.
22+
# Service must listen to $PORT environment variable.
23+
# This default value facilitates local development.
2324
ENV PORT 8080
24-
EXPOSE $PORT
2525

2626
# Run the web service on container startup.
2727
CMD ["/helloworld"]

serving/samples/helloworld-go/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ recreate the source files from this folder.
8080
# Copy the binary to the production image from the builder stage.
8181
COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld
8282
83-
# Configure and document the service HTTP port.
83+
# Service must listen to $PORT environment variable.
84+
# This default value facilitates local development.
8485
ENV PORT 8080
85-
EXPOSE $PORT
8686
8787
# Run the web service on container startup.
8888
CMD ["/helloworld"]

0 commit comments

Comments
 (0)