From 1b6c806ccb2964b7608c33fbffeb718dd3c45ce2 Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <hpandey@pivotal.io> Date: Tue, 7 May 2019 09:20:39 -0700 Subject: [PATCH] Removing the PORT environment variable from Docker file and Java code. (#1211) --- .../hello-world/helloworld-java-spark/Dockerfile | 3 --- .../example/helloworld/HelloWorldApplication.java | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/serving/samples/hello-world/helloworld-java-spark/Dockerfile b/docs/serving/samples/hello-world/helloworld-java-spark/Dockerfile index c0a304795..0eaae5b52 100644 --- a/docs/serving/samples/hello-world/helloworld-java-spark/Dockerfile +++ b/docs/serving/samples/hello-world/helloworld-java-spark/Dockerfile @@ -18,9 +18,6 @@ FROM openjdk:8-jre-alpine # Copy the jar to the production image from the builder stage. COPY --from=builder /app/target/helloworld-0.0.1-SNAPSHOT-jar-with-dependencies.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","-Dserver.port=${PORT}","-jar","/helloworld.jar"] diff --git a/docs/serving/samples/hello-world/helloworld-java-spark/src/main/java/com/example/helloworld/HelloWorldApplication.java b/docs/serving/samples/hello-world/helloworld-java-spark/src/main/java/com/example/helloworld/HelloWorldApplication.java index 30c0c764b..c1a36a198 100644 --- a/docs/serving/samples/hello-world/helloworld-java-spark/src/main/java/com/example/helloworld/HelloWorldApplication.java +++ b/docs/serving/samples/hello-world/helloworld-java-spark/src/main/java/com/example/helloworld/HelloWorldApplication.java @@ -8,10 +8,17 @@ public class HelloWorldApplication { public static void main(String args[]) { - //Default port in SparkJava is 4567 - // Setting the PORT to 8080 here - if(System.getenv("PORT") != null) - port(Integer.valueOf(System.getenv("PORT"))); + + /* + * Please Note: + * Default port in SparkJava is 4567 + * If you wish to use port of your choice, + * uncomment the following code and set the + * required port + */ + + //private static final String PORT = "8080"; + //port(Integer.valueOf(System.getenv("PORT"))); if( System.getenv("TARGET") == null) message = "World";