From 0990f5160911ab5ccaf723fb8f5aa9ac51e3fe20 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Fri, 7 Dec 2018 15:36:22 -0800 Subject: [PATCH 1/3] serving/samples: remove EXPOSE directive from helloworld --- serving/samples/helloworld-clojure/Dockerfile | 3 +-- serving/samples/helloworld-clojure/README.md | 3 +-- serving/samples/helloworld-csharp/Dockerfile | 3 +-- serving/samples/helloworld-csharp/README.md | 1 - serving/samples/helloworld-dart/Dockerfile | 3 +-- serving/samples/helloworld-dart/README.md | 1 - serving/samples/helloworld-elixir/Dockerfile | 1 - serving/samples/helloworld-elixir/README.md | 1 - serving/samples/helloworld-go/Dockerfile | 3 +-- serving/samples/helloworld-go/README.md | 1 - serving/samples/helloworld-haskell/Dockerfile | 3 +-- serving/samples/helloworld-haskell/README.md | 1 - serving/samples/helloworld-java/Dockerfile | 3 +-- serving/samples/helloworld-java/README.md | 1 - serving/samples/helloworld-kotlin/Dockerfile | 3 +-- serving/samples/helloworld-kotlin/README.md | 1 - serving/samples/helloworld-nodejs/Dockerfile | 3 +-- serving/samples/helloworld-nodejs/README.md | 1 - serving/samples/helloworld-php/Dockerfile | 3 +-- serving/samples/helloworld-php/README.md | 1 - serving/samples/helloworld-python/Dockerfile | 3 +-- serving/samples/helloworld-python/README.md | 1 - serving/samples/helloworld-ruby/Dockerfile | 3 +-- serving/samples/helloworld-ruby/README.md | 1 - serving/samples/helloworld-rust/Dockerfile | 3 +-- serving/samples/helloworld-rust/README.md | 1 - serving/samples/helloworld-vertx/Dockerfile | 2 +- serving/samples/helloworld-vertx/README.md | 1 - 28 files changed, 14 insertions(+), 41 deletions(-) diff --git a/serving/samples/helloworld-clojure/Dockerfile b/serving/samples/helloworld-clojure/Dockerfile index 8b8e0894e41..19d926f896c 100644 --- a/serving/samples/helloworld-clojure/Dockerfile +++ b/serving/samples/helloworld-clojure/Dockerfile @@ -13,9 +13,8 @@ COPY . . # Build an uberjar release artifact. 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. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["java", "-jar", "app-standalone.jar"] diff --git a/serving/samples/helloworld-clojure/README.md b/serving/samples/helloworld-clojure/README.md index 0d9742b2c2e..f5bbac37dd2 100644 --- a/serving/samples/helloworld-clojure/README.md +++ b/serving/samples/helloworld-clojure/README.md @@ -75,9 +75,8 @@ recreate the source files from this folder. # Build an uberjar release artifact. 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. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["java", "-jar", "app-standalone.jar"] diff --git a/serving/samples/helloworld-csharp/Dockerfile b/serving/samples/helloworld-csharp/Dockerfile index 1bf2cab0b56..c8fbe50a4e5 100644 --- a/serving/samples/helloworld-csharp/Dockerfile +++ b/serving/samples/helloworld-csharp/Dockerfile @@ -14,9 +14,8 @@ COPY . . # Build a release artifact. RUN dotnet publish -c Release -o out -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["dotnet", "out/helloworld-csharp.dll"] diff --git a/serving/samples/helloworld-csharp/README.md b/serving/samples/helloworld-csharp/README.md index 12da5607c0d..21395cf0dd4 100644 --- a/serving/samples/helloworld-csharp/README.md +++ b/serving/samples/helloworld-csharp/README.md @@ -74,7 +74,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["dotnet", "out/helloworld-csharp.dll"] diff --git a/serving/samples/helloworld-dart/Dockerfile b/serving/samples/helloworld-dart/Dockerfile index 6066d9c4d66..dc03bdd4c3e 100644 --- a/serving/samples/helloworld-dart/Dockerfile +++ b/serving/samples/helloworld-dart/Dockerfile @@ -2,6 +2,5 @@ # https://hub.docker.com/r/google/dart-runtime/ FROM google/dart-runtime -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT diff --git a/serving/samples/helloworld-dart/README.md b/serving/samples/helloworld-dart/README.md index 666af52c783..53f89488762 100644 --- a/serving/samples/helloworld-dart/README.md +++ b/serving/samples/helloworld-dart/README.md @@ -78,7 +78,6 @@ be created using the following instructions. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT ``` 5. Create a new file, `service.yaml` and copy the following service definition diff --git a/serving/samples/helloworld-elixir/Dockerfile b/serving/samples/helloworld-elixir/Dockerfile index fd5395a7614..37ae5ac71df 100644 --- a/serving/samples/helloworld-elixir/Dockerfile +++ b/serving/samples/helloworld-elixir/Dockerfile @@ -33,7 +33,6 @@ USER appuser ENV PORT=8080 MIX_ENV=prod REPLACE_OS_VARS=true WORKDIR /opt/app -EXPOSE 8080 COPY --from=0 /opt/release . ENV RUNNER_LOG_DIR /var/log CMD ["/opt/app/bin/start_server", "foreground", "boot_var=/tmp"] diff --git a/serving/samples/helloworld-elixir/README.md b/serving/samples/helloworld-elixir/README.md index 96cf4024a18..3cc0de2442b 100644 --- a/serving/samples/helloworld-elixir/README.md +++ b/serving/samples/helloworld-elixir/README.md @@ -84,7 +84,6 @@ When asked, if you want to `Fetch and install dependencies? [Yn]` select `y` # Document that the service listens on port 8080. ENV PORT=8080 MIX_ENV=prod REPLACE_OS_VARS=true WORKDIR /opt/app - EXPOSE 8080 COPY --from=0 /opt/release . ENV RUNNER_LOG_DIR /var/log diff --git a/serving/samples/helloworld-go/Dockerfile b/serving/samples/helloworld-go/Dockerfile index 7ded7358346..6523b58f6f6 100644 --- a/serving/samples/helloworld-go/Dockerfile +++ b/serving/samples/helloworld-go/Dockerfile @@ -18,9 +18,8 @@ FROM alpine # Copy the binary to the production image from the builder stage. COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["/helloworld"] diff --git a/serving/samples/helloworld-go/README.md b/serving/samples/helloworld-go/README.md index 744e591b490..7892774b9d8 100644 --- a/serving/samples/helloworld-go/README.md +++ b/serving/samples/helloworld-go/README.md @@ -81,7 +81,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["/helloworld"] diff --git a/serving/samples/helloworld-haskell/Dockerfile b/serving/samples/helloworld-haskell/Dockerfile index 3a5871619e5..2b0b67836be 100644 --- a/serving/samples/helloworld-haskell/Dockerfile +++ b/serving/samples/helloworld-haskell/Dockerfile @@ -18,9 +18,8 @@ FROM fpco/haskell-scratch:integer-gmp WORKDIR /root/ COPY --from=builder /root/.local/bin/helloworld-haskell-exe . -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["./helloworld-haskell-exe"] diff --git a/serving/samples/helloworld-haskell/README.md b/serving/samples/helloworld-haskell/README.md index 82565bc1c3c..e0b8d57d023 100644 --- a/serving/samples/helloworld-haskell/README.md +++ b/serving/samples/helloworld-haskell/README.md @@ -103,7 +103,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["./helloworld-haskell-exe"] diff --git a/serving/samples/helloworld-java/Dockerfile b/serving/samples/helloworld-java/Dockerfile index 6e2290853d8..7f0f9020340 100644 --- a/serving/samples/helloworld-java/Dockerfile +++ b/serving/samples/helloworld-java/Dockerfile @@ -18,9 +18,8 @@ FROM openjdk:8-jre-alpine # Copy the jar to the production image from the builder stage. COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/helloworld.jar"] diff --git a/serving/samples/helloworld-java/README.md b/serving/samples/helloworld-java/README.md index f3ff63a24fc..e76ad62378a 100644 --- a/serving/samples/helloworld-java/README.md +++ b/serving/samples/helloworld-java/README.md @@ -109,7 +109,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/helloworld.jar"] diff --git a/serving/samples/helloworld-kotlin/Dockerfile b/serving/samples/helloworld-kotlin/Dockerfile index 4eb2de019a7..3089cf970cd 100644 --- a/serving/samples/helloworld-kotlin/Dockerfile +++ b/serving/samples/helloworld-kotlin/Dockerfile @@ -17,9 +17,8 @@ FROM openjdk:8-jre-alpine # Copy the jar to the production image from the builder stage. COPY --from=builder /home/gradle/build/libs/gradle.jar /helloworld.jar -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "/helloworld.jar" ] diff --git a/serving/samples/helloworld-kotlin/README.md b/serving/samples/helloworld-kotlin/README.md index 34011446ad1..26be218bcd7 100644 --- a/serving/samples/helloworld-kotlin/README.md +++ b/serving/samples/helloworld-kotlin/README.md @@ -130,7 +130,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "/helloworld.jar" ] diff --git a/serving/samples/helloworld-nodejs/Dockerfile b/serving/samples/helloworld-nodejs/Dockerfile index 4e701f87155..806fe010b29 100644 --- a/serving/samples/helloworld-nodejs/Dockerfile +++ b/serving/samples/helloworld-nodejs/Dockerfile @@ -16,9 +16,8 @@ RUN npm install --only=production # Copy local code to the container image. COPY . . -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD [ "npm", "start" ] diff --git a/serving/samples/helloworld-nodejs/README.md b/serving/samples/helloworld-nodejs/README.md index a02afb9cceb..042728c5238 100644 --- a/serving/samples/helloworld-nodejs/README.md +++ b/serving/samples/helloworld-nodejs/README.md @@ -104,7 +104,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD [ "npm", "start" ] diff --git a/serving/samples/helloworld-php/Dockerfile b/serving/samples/helloworld-php/Dockerfile index 26c49a55150..44f879b7b0f 100644 --- a/serving/samples/helloworld-php/Dockerfile +++ b/serving/samples/helloworld-php/Dockerfile @@ -8,6 +8,5 @@ COPY index.php /var/www/html/ # Use the PORT environment variable in Apache configuration files. RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT diff --git a/serving/samples/helloworld-php/README.md b/serving/samples/helloworld-php/README.md index d6610270117..43c580fc909 100644 --- a/serving/samples/helloworld-php/README.md +++ b/serving/samples/helloworld-php/README.md @@ -49,7 +49,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT ``` 1. Create a new file, `service.yaml` and copy the following service definition diff --git a/serving/samples/helloworld-python/Dockerfile b/serving/samples/helloworld-python/Dockerfile index 1875f5bdec8..0cb47a1b556 100644 --- a/serving/samples/helloworld-python/Dockerfile +++ b/serving/samples/helloworld-python/Dockerfile @@ -10,9 +10,8 @@ COPY . . # Install production dependencies. RUN pip install Flask -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["python", "app.py"] diff --git a/serving/samples/helloworld-python/README.md b/serving/samples/helloworld-python/README.md index e88e4f46f9b..82733286937 100644 --- a/serving/samples/helloworld-python/README.md +++ b/serving/samples/helloworld-python/README.md @@ -62,7 +62,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["python", "app.py"] diff --git a/serving/samples/helloworld-ruby/Dockerfile b/serving/samples/helloworld-ruby/Dockerfile index 7077135d8a8..25891e34794 100644 --- a/serving/samples/helloworld-ruby/Dockerfile +++ b/serving/samples/helloworld-ruby/Dockerfile @@ -11,9 +11,8 @@ RUN bundle install # Copy local code to the container image. COPY . . -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["ruby", "./app.rb"] diff --git a/serving/samples/helloworld-ruby/README.md b/serving/samples/helloworld-ruby/README.md index 20ef49faeb7..5b392aaa843 100644 --- a/serving/samples/helloworld-ruby/README.md +++ b/serving/samples/helloworld-ruby/README.md @@ -58,7 +58,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["ruby", "./app.rb"] diff --git a/serving/samples/helloworld-rust/Dockerfile b/serving/samples/helloworld-rust/Dockerfile index 84d3c30c18e..d81509f89e1 100644 --- a/serving/samples/helloworld-rust/Dockerfile +++ b/serving/samples/helloworld-rust/Dockerfile @@ -9,9 +9,8 @@ COPY . . # Install production dependencies and build a release artifact. RUN cargo install -# Configure and document the service HTTP port. +# Configure the service HTTP port. ENV PORT 8080 -EXPOSE $PORT # Run the web service on container startup. CMD ["hellorust"] diff --git a/serving/samples/helloworld-rust/README.md b/serving/samples/helloworld-rust/README.md index a8971c9db41..f5b0eca8fa3 100644 --- a/serving/samples/helloworld-rust/README.md +++ b/serving/samples/helloworld-rust/README.md @@ -101,7 +101,6 @@ recreate the source files from this folder. # Configure and document the service HTTP port. ENV PORT 8080 - EXPOSE $PORT # Run the web service on container startup. CMD ["hellorust"] diff --git a/serving/samples/helloworld-vertx/Dockerfile b/serving/samples/helloworld-vertx/Dockerfile index 5bbee10eda9..2c5d306c00d 100644 --- a/serving/samples/helloworld-vertx/Dockerfile +++ b/serving/samples/helloworld-vertx/Dockerfile @@ -1,5 +1,5 @@ FROM fabric8/s2i-java:2.0 ENV JAVA_APP_DIR=/deployments -EXPOSE 8080 +ENV PORT 8080 COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ diff --git a/serving/samples/helloworld-vertx/README.md b/serving/samples/helloworld-vertx/README.md index 68ed1806b00..af821b356de 100644 --- a/serving/samples/helloworld-vertx/README.md +++ b/serving/samples/helloworld-vertx/README.md @@ -146,7 +146,6 @@ To create and configure the source files in the root of your working directory: ```docker FROM fabric8/s2i-java:2.0 ENV JAVA_APP_DIR=/deployments - EXPOSE 8080 COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ ``` From ee93f69c8efdf2b29c274204d262d12b81a2b0a5 Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Thu, 3 Jan 2019 11:26:26 -0800 Subject: [PATCH 2/3] serving/samples: update ENV PORT comment for clarified purpose --- serving/samples/helloworld-clojure/Dockerfile | 3 ++- serving/samples/helloworld-csharp/Dockerfile | 3 ++- serving/samples/helloworld-dart/Dockerfile | 3 ++- serving/samples/helloworld-go/Dockerfile | 3 ++- serving/samples/helloworld-haskell/Dockerfile | 3 ++- serving/samples/helloworld-java/Dockerfile | 3 ++- serving/samples/helloworld-kotlin/Dockerfile | 3 ++- serving/samples/helloworld-nodejs/Dockerfile | 3 ++- serving/samples/helloworld-php/Dockerfile | 3 ++- serving/samples/helloworld-python/Dockerfile | 3 ++- serving/samples/helloworld-ruby/Dockerfile | 3 ++- serving/samples/helloworld-rust/Dockerfile | 3 ++- serving/samples/helloworld-vertx/Dockerfile | 10 ++++++++-- 13 files changed, 32 insertions(+), 14 deletions(-) diff --git a/serving/samples/helloworld-clojure/Dockerfile b/serving/samples/helloworld-clojure/Dockerfile index 19d926f896c..ac1d66d5d40 100644 --- a/serving/samples/helloworld-clojure/Dockerfile +++ b/serving/samples/helloworld-clojure/Dockerfile @@ -13,7 +13,8 @@ COPY . . # Build an uberjar release artifact. RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-csharp/Dockerfile b/serving/samples/helloworld-csharp/Dockerfile index c8fbe50a4e5..10dd884c4da 100644 --- a/serving/samples/helloworld-csharp/Dockerfile +++ b/serving/samples/helloworld-csharp/Dockerfile @@ -14,7 +14,8 @@ COPY . . # Build a release artifact. RUN dotnet publish -c Release -o out -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-dart/Dockerfile b/serving/samples/helloworld-dart/Dockerfile index dc03bdd4c3e..4d00aa6fbda 100644 --- a/serving/samples/helloworld-dart/Dockerfile +++ b/serving/samples/helloworld-dart/Dockerfile @@ -2,5 +2,6 @@ # https://hub.docker.com/r/google/dart-runtime/ FROM google/dart-runtime -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 diff --git a/serving/samples/helloworld-go/Dockerfile b/serving/samples/helloworld-go/Dockerfile index 6523b58f6f6..cb252ab25b7 100644 --- a/serving/samples/helloworld-go/Dockerfile +++ b/serving/samples/helloworld-go/Dockerfile @@ -18,7 +18,8 @@ FROM alpine # Copy the binary to the production image from the builder stage. COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-haskell/Dockerfile b/serving/samples/helloworld-haskell/Dockerfile index 2b0b67836be..ec479234c68 100644 --- a/serving/samples/helloworld-haskell/Dockerfile +++ b/serving/samples/helloworld-haskell/Dockerfile @@ -18,7 +18,8 @@ FROM fpco/haskell-scratch:integer-gmp WORKDIR /root/ COPY --from=builder /root/.local/bin/helloworld-haskell-exe . -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-java/Dockerfile b/serving/samples/helloworld-java/Dockerfile index 7f0f9020340..750b905fdfe 100644 --- a/serving/samples/helloworld-java/Dockerfile +++ b/serving/samples/helloworld-java/Dockerfile @@ -18,7 +18,8 @@ FROM openjdk:8-jre-alpine # Copy the jar to the production image from the builder stage. COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-kotlin/Dockerfile b/serving/samples/helloworld-kotlin/Dockerfile index 3089cf970cd..69d23f8c2d1 100644 --- a/serving/samples/helloworld-kotlin/Dockerfile +++ b/serving/samples/helloworld-kotlin/Dockerfile @@ -17,7 +17,8 @@ FROM openjdk:8-jre-alpine # Copy the jar to the production image from the builder stage. COPY --from=builder /home/gradle/build/libs/gradle.jar /helloworld.jar -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-nodejs/Dockerfile b/serving/samples/helloworld-nodejs/Dockerfile index 806fe010b29..b41a0aa3339 100644 --- a/serving/samples/helloworld-nodejs/Dockerfile +++ b/serving/samples/helloworld-nodejs/Dockerfile @@ -16,7 +16,8 @@ RUN npm install --only=production # Copy local code to the container image. COPY . . -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-php/Dockerfile b/serving/samples/helloworld-php/Dockerfile index 44f879b7b0f..6af811ae6f1 100644 --- a/serving/samples/helloworld-php/Dockerfile +++ b/serving/samples/helloworld-php/Dockerfile @@ -8,5 +8,6 @@ COPY index.php /var/www/html/ # Use the PORT environment variable in Apache configuration files. RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 diff --git a/serving/samples/helloworld-python/Dockerfile b/serving/samples/helloworld-python/Dockerfile index 0cb47a1b556..e0bfa7b3118 100644 --- a/serving/samples/helloworld-python/Dockerfile +++ b/serving/samples/helloworld-python/Dockerfile @@ -10,7 +10,8 @@ COPY . . # Install production dependencies. RUN pip install Flask -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-ruby/Dockerfile b/serving/samples/helloworld-ruby/Dockerfile index 25891e34794..c3114cb495f 100644 --- a/serving/samples/helloworld-ruby/Dockerfile +++ b/serving/samples/helloworld-ruby/Dockerfile @@ -11,7 +11,8 @@ RUN bundle install # Copy local code to the container image. COPY . . -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-rust/Dockerfile b/serving/samples/helloworld-rust/Dockerfile index d81509f89e1..10073fc6c2f 100644 --- a/serving/samples/helloworld-rust/Dockerfile +++ b/serving/samples/helloworld-rust/Dockerfile @@ -9,7 +9,8 @@ COPY . . # Install production dependencies and build a release artifact. RUN cargo install -# Configure the service HTTP port. +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 # Run the web service on container startup. diff --git a/serving/samples/helloworld-vertx/Dockerfile b/serving/samples/helloworld-vertx/Dockerfile index 2c5d306c00d..0fe5bec6cb5 100644 --- a/serving/samples/helloworld-vertx/Dockerfile +++ b/serving/samples/helloworld-vertx/Dockerfile @@ -1,5 +1,11 @@ +# Use fabric8's s2i Builder image. +# https://hub.docker.com/r/fabric8/s2i-java FROM fabric8/s2i-java:2.0 -ENV JAVA_APP_DIR=/deployments + +# Service must listen to $PORT environment variable. +# This default value facilitates local development. ENV PORT 8080 -COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ +# Copy the JAR file to the deployment directory. +ENV JAVA_APP_DIR=/deployments +COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ From 6027abe40af3453758a9f7b5c47ad5e53383cf3d Mon Sep 17 00:00:00 2001 From: Adam Ross Date: Thu, 3 Jan 2019 15:20:46 -0800 Subject: [PATCH 3/3] serving/samples: update README for Dockerfile changes --- serving/samples/helloworld-clojure/README.md | 35 +++++++------ serving/samples/helloworld-csharp/README.md | 47 +++++++++-------- serving/samples/helloworld-dart/README.md | 17 +++--- serving/samples/helloworld-go/README.md | 55 ++++++++++---------- serving/samples/helloworld-haskell/README.md | 55 ++++++++++---------- serving/samples/helloworld-java/Dockerfile | 1 - serving/samples/helloworld-java/README.md | 55 ++++++++++---------- serving/samples/helloworld-kotlin/README.md | 41 ++++++++------- serving/samples/helloworld-nodejs/README.md | 39 +++++++------- serving/samples/helloworld-php/README.md | 23 ++++---- serving/samples/helloworld-python/README.md | 39 +++++++------- serving/samples/helloworld-ruby/README.md | 41 ++++++++------- serving/samples/helloworld-rust/README.md | 29 ++++++----- serving/samples/helloworld-vertx/README.md | 18 +++++-- 14 files changed, 257 insertions(+), 238 deletions(-) diff --git a/serving/samples/helloworld-clojure/README.md b/serving/samples/helloworld-clojure/README.md index f5bbac37dd2..2da4381da70 100644 --- a/serving/samples/helloworld-clojure/README.md +++ b/serving/samples/helloworld-clojure/README.md @@ -59,28 +59,29 @@ recreate the source files from this folder. see [the clojure image documentation](https://github.com/docker-library/docs/tree/master/clojure). - ```docker - # Use the official Clojure image. - # https://hub.docker.com/_/clojure - FROM clojure + ```docker + # Use the official Clojure image. + # https://hub.docker.com/_/clojure + FROM clojure - # Create the project and download dependencies. - WORKDIR /usr/src/app - COPY project.clj . - RUN lein deps + # Create the project and download dependencies. + WORKDIR /usr/src/app + COPY project.clj . + RUN lein deps - # Copy local code to the container image. - COPY . . + # Copy local code to the container image. + COPY . . - # Build an uberjar release artifact. - RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar + # Build an uberjar release artifact. + RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar - # Configure the service HTTP port. - ENV PORT 8080 + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 - # Run the web service on container startup. - CMD ["java", "-jar", "app-standalone.jar"] - ``` + # Run the web service on container startup. + CMD ["java", "-jar", "app-standalone.jar"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-csharp/README.md b/serving/samples/helloworld-csharp/README.md index 21395cf0dd4..03bab14d383 100644 --- a/serving/samples/helloworld-csharp/README.md +++ b/serving/samples/helloworld-csharp/README.md @@ -55,29 +55,30 @@ recreate the source files from this folder. app, see [dockerizing a .NET core app](https://docs.microsoft.com/en-us/dotnet/core/docker/docker-basics-dotnet-core#dockerize-the-net-core-application). - ```docker - # Use Microsoft's official .NET image. - # https://hub.docker.com/r/microsoft/dotnet - FROM microsoft/dotnet:2.1-sdk - - # Install production dependencies. - # Copy csproj and restore as distinct layers. - WORKDIR /app - COPY *.csproj . - RUN dotnet restore - - # Copy local code to the container image. - COPY . . - - # Build a release artifact. - RUN dotnet publish -c Release -o out - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["dotnet", "out/helloworld-csharp.dll"] - ``` + ```docker + # Use Microsoft's official .NET image. + # https://hub.docker.com/r/microsoft/dotnet + FROM microsoft/dotnet:2.1-sdk + + # Install production dependencies. + # Copy csproj and restore as distinct layers. + WORKDIR /app + COPY *.csproj . + RUN dotnet restore + + # Copy local code to the container image. + COPY . . + + # Build a release artifact. + RUN dotnet publish -c Release -o out + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["dotnet", "out/helloworld-csharp.dll"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-dart/README.md b/serving/samples/helloworld-dart/README.md index 53f89488762..e7d8303ee8b 100644 --- a/serving/samples/helloworld-dart/README.md +++ b/serving/samples/helloworld-dart/README.md @@ -71,14 +71,15 @@ be created using the following instructions. 4. Create a new file named `Dockerfile`, this file defines instructions for dockerizing your applications, for dart apps this can be done as follows: - ```Dockerfile - # Use Google's official Dart image. - # https://hub.docker.com/r/google/dart-runtime/ - FROM google/dart-runtime - - # Configure and document the service HTTP port. - ENV PORT 8080 - ``` + ```Dockerfile + # Use Google's official Dart image. + # https://hub.docker.com/r/google/dart-runtime/ + FROM google/dart-runtime + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + ``` 5. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-go/README.md b/serving/samples/helloworld-go/README.md index 7892774b9d8..51eebc1668f 100644 --- a/serving/samples/helloworld-go/README.md +++ b/serving/samples/helloworld-go/README.md @@ -58,33 +58,34 @@ recreate the source files from this folder. block below into it. For detailed instructions on dockerizing a Go app, see [Deploying Go servers with Docker](https://blog.golang.org/docker). - ```docker - # Use the offical Golang image to create a build artifact. - # This is based on Debian and sets the GOPATH to /go. - FROM golang as builder - - # Copy local code to the container image. - WORKDIR /go/src/github.com/knative/docs/helloworld - COPY . . - - # Build the helloworld command inside the container. - # (You may fetch or manage dependencies here, - # either manually or with a tool like "godep".) - RUN CGO_ENABLED=0 GOOS=linux go build -v -o helloworld - - # Use a Docker multi-stage build to create a lean production image. - # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds - FROM alpine - - # Copy the binary to the production image from the builder stage. - COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["/helloworld"] - ``` + ```docker + # Use the offical Golang image to create a build artifact. + # This is based on Debian and sets the GOPATH to /go. + FROM golang as builder + + # Copy local code to the container image. + WORKDIR /go/src/github.com/knative/docs/helloworld + COPY . . + + # Build the outyet command inside the container. + # (You may fetch or manage dependencies here, + # either manually or with a tool like "godep".) + RUN CGO_ENABLED=0 GOOS=linux go build -v -o helloworld + + # Use a Docker multi-stage build to create a lean production image. + # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds + FROM alpine + + # Copy the binary to the production image from the builder stage. + COPY --from=builder /go/src/github.com/knative/docs/helloworld/helloworld /helloworld + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["/helloworld"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-haskell/README.md b/serving/samples/helloworld-haskell/README.md index e0b8d57d023..6f251c6d25f 100644 --- a/serving/samples/helloworld-haskell/README.md +++ b/serving/samples/helloworld-haskell/README.md @@ -80,33 +80,34 @@ recreate the source files from this folder. 1. In your project directory, create a file named `Dockerfile` and copy the code block below into it. - ```docker - # Use the official Haskell image to create a build artifact. - # https://hub.docker.com/_/haskell/ - FROM haskell:8.2.2 as builder - - # Copy local code to the container image. - WORKDIR /app - COPY . . - - # Build and test our code, then build the “helloworld-haskell-exe” executable. - RUN stack setup - RUN stack build --copy-bins - - # Use a Docker multi-stage build to create a lean production image. - # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds - FROM fpco/haskell-scratch:integer-gmp - - # Copy the "helloworld-haskell-exe" executable from the builder stage to the production image. - WORKDIR /root/ - COPY --from=builder /root/.local/bin/helloworld-haskell-exe . - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["./helloworld-haskell-exe"] - ``` + ```docker + # Use the official Haskell image to create a build artifact. + # https://hub.docker.com/_/haskell/ + FROM haskell:8.2.2 as builder + + # Copy local code to the container image. + WORKDIR /app + COPY . . + + # Build and test our code, then build the “helloworld-haskell-exe” executable. + RUN stack setup + RUN stack build --copy-bins + + # Use a Docker multi-stage build to create a lean production image. + # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds + FROM fpco/haskell-scratch:integer-gmp + + # Copy the "helloworld-haskell-exe" executable from the builder stage to the production image. + WORKDIR /root/ + COPY --from=builder /root/.local/bin/helloworld-haskell-exe . + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["./helloworld-haskell-exe"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-java/Dockerfile b/serving/samples/helloworld-java/Dockerfile index 750b905fdfe..159b36e5f8c 100644 --- a/serving/samples/helloworld-java/Dockerfile +++ b/serving/samples/helloworld-java/Dockerfile @@ -24,4 +24,3 @@ ENV PORT 8080 # Run the web service on container startup. CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/helloworld.jar"] - diff --git a/serving/samples/helloworld-java/README.md b/serving/samples/helloworld-java/README.md index e76ad62378a..717f8179ec3 100644 --- a/serving/samples/helloworld-java/README.md +++ b/serving/samples/helloworld-java/README.md @@ -86,33 +86,34 @@ recreate the source files from this folder. For additional information on multi-stage docker builds for Java see [Creating Smaller Java Image using Docker Multi-stage Build](http://blog.arungupta.me/smaller-java-image-docker-multi-stage-build/). - ```docker - # Use the official maven/Java 8 image to create a build artifact. - # https://hub.docker.com/_/maven - FROM maven:3.5-jdk-8-alpine as builder - - # Copy local code to the container image. - WORKDIR /app - COPY pom.xml . - COPY src ./src - - # Build a release artifact. - RUN mvn package -DskipTests - - # Use the Official OpenJDK image for a lean production stage of our multi-stage build. - # https://hub.docker.com/_/openjdk - # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds - FROM openjdk:8-jre-alpine - - # Copy the jar to the production image from the builder stage. - COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/helloworld.jar"] - ``` + ```docker + # Use the official maven/Java 8 image to create a build artifact. + # https://hub.docker.com/_/maven + FROM maven:3.5-jdk-8-alpine as builder + + # Copy local code to the container image. + WORKDIR /app + COPY pom.xml . + COPY src ./src + + # Build a release artifact. + RUN mvn package -DskipTests + + # Use the Official OpenJDK image for a lean production stage of our multi-stage build. + # https://hub.docker.com/_/openjdk + # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds + FROM openjdk:8-jre-alpine + + # Copy the jar to the production image from the builder stage. + COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["java","-Djava.security.egd=file:/dev/./urandom","-Dserver.port=${PORT}","-jar","/helloworld.jar"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-kotlin/README.md b/serving/samples/helloworld-kotlin/README.md index 26be218bcd7..e73107babe2 100644 --- a/serving/samples/helloworld-kotlin/README.md +++ b/serving/samples/helloworld-kotlin/README.md @@ -108,32 +108,33 @@ recreate the source files from this folder. 5. Create a file named `Dockerfile` and copy the code block below into it. - ```docker - # Use the official gradle image to create a build artifact. - # https://hub.docker.com/_/gradle - FROM gradle as builder + ```docker + # Use the official gradle image to create a build artifact. + # https://hub.docker.com/_/gradle + FROM gradle as builder - # Copy local code to the container image. - COPY build.gradle . - COPY src ./src + # Copy local code to the container image. + COPY build.gradle . + COPY src ./src - # Build a release artifact. - RUN gradle clean build --no-daemon + # Build a release artifact. + RUN gradle clean build --no-daemon - # Use the Official OpenJDK image for a lean production stage of our multi-stage build. - # https://hub.docker.com/_/openjdk - # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds - FROM openjdk:8-jre-alpine + # Use the Official OpenJDK image for a lean production stage of our multi-stage build. + # https://hub.docker.com/_/openjdk + # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds + FROM openjdk:8-jre-alpine - # Copy the jar to the production image from the builder stage. - COPY --from=builder /home/gradle/build/libs/gradle.jar /helloworld.jar + # Copy the jar to the production image from the builder stage. + COPY --from=builder /home/gradle/build/libs/gradle.jar /helloworld.jar - # Configure and document the service HTTP port. - ENV PORT 8080 + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 - # Run the web service on container startup. - CMD [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "/helloworld.jar" ] - ``` + # Run the web service on container startup. + CMD [ "java", "-jar", "-Djava.security.egd=file:/dev/./urandom", "/helloworld.jar" ] + ``` 6. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-nodejs/README.md b/serving/samples/helloworld-nodejs/README.md index 042728c5238..32c4563f593 100644 --- a/serving/samples/helloworld-nodejs/README.md +++ b/serving/samples/helloworld-nodejs/README.md @@ -83,31 +83,32 @@ recreate the source files from this folder. see [Dockerizing a Node.js web app](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/). - ```Dockerfile - # Use the official Node 8 image. - # https://hub.docker.com/_/node - FROM node:8 + ```Dockerfile + # Use the official Node 8 image. + # https://hub.docker.com/_/node + FROM node:10 - # Create and change to the app directory. - WORKDIR /usr/src/app + # Create and change to the app directory. + WORKDIR /usr/src/app - # Copy application dependency manifests to the container image. - # A wildcard is used to ensure both package.json AND package-lock.json are copied. - # Copying this separately prevents re-running npm install on every code change. - COPY package*.json ./ + # Copy application dependency manifests to the container image. + # A wildcard is used to ensure both package.json AND package-lock.json are copied. + # Copying this separately prevents re-running npm install on every code change. + COPY package*.json ./ - # Install production dependencies. - RUN npm install --only=production + # Install production dependencies. + RUN npm install --only=production - # Copy local code to the container image. - COPY . . + # Copy local code to the container image. + COPY . . - # Configure and document the service HTTP port. - ENV PORT 8080 + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 - # Run the web service on container startup. - CMD [ "npm", "start" ] - ``` + # Run the web service on container startup. + CMD [ "npm", "start" ] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-php/README.md b/serving/samples/helloworld-php/README.md index 43c580fc909..af99ba3519e 100644 --- a/serving/samples/helloworld-php/README.md +++ b/serving/samples/helloworld-php/README.md @@ -36,20 +36,21 @@ recreate the source files from this folder. 1. Create a file named `Dockerfile` and copy the code block below into it. See [official PHP docker image](https://hub.docker.com/_/php/) for more details. - ```docker - # Use the official PHP 7.2 image. - # https://hub.docker.com/_/php - FROM php:7.2.6-apache + ```docker + # Use the official PHP 7.2 image. + # https://hub.docker.com/_/php + FROM php:7.2.6-apache - # Copy local code to the container image. - COPY index.php /var/www/html/ + # Copy local code to the container image. + COPY index.php /var/www/html/ - # Use the PORT environment variable in Apache configuration files. - RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf + # Use the PORT environment variable in Apache configuration files. + RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf - # Configure and document the service HTTP port. - ENV PORT 8080 - ``` + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-python/README.md b/serving/samples/helloworld-python/README.md index 82733286937..00ba6dd68af 100644 --- a/serving/samples/helloworld-python/README.md +++ b/serving/samples/helloworld-python/README.md @@ -47,25 +47,26 @@ recreate the source files from this folder. [official Python docker image](https://hub.docker.com/_/python/) for more details. - ```docker - # Use the official Python image. - # https://hub.docker.com/_/python - FROM python - - # Copy local code to the container image. - ENV APP_HOME /app - WORKDIR $APP_HOME - COPY . . - - # Install production dependencies. - RUN pip install Flask - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["python", "app.py"] - ``` + ```docker + # Use the official Python image. + # https://hub.docker.com/_/python + FROM python + + # Copy local code to the container image. + ENV APP_HOME /app + WORKDIR $APP_HOME + COPY . . + + # Install production dependencies. + RUN pip install Flask + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["python", "app.py"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-ruby/README.md b/serving/samples/helloworld-ruby/README.md index 5b392aaa843..77441c6d435 100644 --- a/serving/samples/helloworld-ruby/README.md +++ b/serving/samples/helloworld-ruby/README.md @@ -42,26 +42,27 @@ recreate the source files from this folder. [official Ruby docker image](https://hub.docker.com/_/ruby/) for more details. - ```docker - # Use the official Ruby image. - # https://hub.docker.com/_/ruby - FROM ruby:2.5 - - # Install production dependencies. - WORKDIR /usr/src/app - COPY Gemfile Gemfile.lock ./ - ENV BUNDLE_FROZEN=true - RUN bundle install - - # Copy local code to the container image. - COPY . . - - # Configure and document the service HTTP port. - ENV PORT 8080 - - # Run the web service on container startup. - CMD ["ruby", "./app.rb"] - ``` + ```docker + # Use the official Ruby image. + # https://hub.docker.com/_/ruby + FROM ruby:2.5 + + # Install production dependencies. + WORKDIR /usr/src/app + COPY Gemfile Gemfile.lock ./ + ENV BUNDLE_FROZEN=true + RUN bundle install + + # Copy local code to the container image. + COPY . . + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Run the web service on container startup. + CMD ["ruby", "./app.rb"] + ``` 1. Create a file named `Gemfile` and copy the text block below into it. diff --git a/serving/samples/helloworld-rust/README.md b/serving/samples/helloworld-rust/README.md index f5b0eca8fa3..ba03aaf54c0 100644 --- a/serving/samples/helloworld-rust/README.md +++ b/serving/samples/helloworld-rust/README.md @@ -87,24 +87,25 @@ recreate the source files from this folder. 1. In your project directory, create a file named `Dockerfile` and copy the code block below into it. - ```docker - # Use the official Rust image. - # https://hub.docker.com/_/rust - FROM rust:1.27.0 + ```docker + # Use the official Rust image. + # https://hub.docker.com/_/rust + FROM rust:1.27.0 - # Copy local code to the container image. - WORKDIR /usr/src/app - COPY . . + # Copy local code to the container image. + WORKDIR /usr/src/app + COPY . . - # Install production dependencies and build a release artifact. - RUN cargo install + # Install production dependencies and build a release artifact. + RUN cargo install - # Configure and document the service HTTP port. - ENV PORT 8080 + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 - # Run the web service on container startup. - CMD ["hellorust"] - ``` + # Run the web service on container startup. + CMD ["hellorust"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/serving/samples/helloworld-vertx/README.md b/serving/samples/helloworld-vertx/README.md index af821b356de..3912beafa47 100644 --- a/serving/samples/helloworld-vertx/README.md +++ b/serving/samples/helloworld-vertx/README.md @@ -143,11 +143,19 @@ To create and configure the source files in the root of your working directory: 1. Create the `Dockerfile` file: - ```docker - FROM fabric8/s2i-java:2.0 - ENV JAVA_APP_DIR=/deployments - COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ - ``` + ```docker + # Use fabric8's s2i Builder image. + # https://hub.docker.com/r/fabric8/s2i-java + FROM fabric8/s2i-java:2.0 + + # Service must listen to $PORT environment variable. + # This default value facilitates local development. + ENV PORT 8080 + + # Copy the JAR file to the deployment directory. + ENV JAVA_APP_DIR=/deployments + COPY target/helloworld-1.0.0-SNAPSHOT.jar /deployments/ + ``` 1. Create the `service.yaml` file. You must specify your Docker Hub username in `{username}`. You can also configure the `TARGET`, for example you can modify