You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/08/16 14:53:48 UTC

cxf git commit: Initial Docker work on spring_boot_scan

Repository: cxf
Updated Branches:
  refs/heads/master a2ef88d6a -> ce3de8e35


Initial Docker work on spring_boot_scan


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ce3de8e3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ce3de8e3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ce3de8e3

Branch: refs/heads/master
Commit: ce3de8e355a58fae2c52e89d1fd37c80a60e2d6b
Parents: a2ef88d
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Wed Aug 16 15:53:05 2017 +0100
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Wed Aug 16 15:53:05 2017 +0100

----------------------------------------------------------------------
 .../samples/jax_rs/spring_boot/Dockerfile       |  4 +-
 .../release/samples/jax_rs/spring_boot/README   |  5 +-
 .../release/samples/jax_rs/spring_boot/pom.xml  |  2 +-
 .../spring_boot_scan/application/Dockerfile     |  5 ++
 .../jax_rs/spring_boot_scan/application/README  | 45 +++++++++++++----
 .../jax_rs/spring_boot_scan/application/pom.xml | 53 +++++++++++++++++---
 .../src/main/resources/application.yml          |  2 +-
 .../jax_rs/spring_boot_scan/client/pom.xml      |  2 +-
 .../spring_boot_scan/eureka-registry/Dockerfile |  6 +++
 .../spring_boot_scan/eureka-registry/README     | 35 +++++++++++--
 .../spring_boot_scan/eureka-registry/pom.xml    | 28 ++++++++++-
 11 files changed, 157 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot/Dockerfile
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/Dockerfile b/distribution/src/main/release/samples/jax_rs/spring_boot/Dockerfile
index 57ef253..d4c8390 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot/Dockerfile
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot/Dockerfile
@@ -1,5 +1,5 @@
 FROM openjdk:8-jdk-alpine
 VOLUME /tmp
-ADD target/spring-boot-sample-rs-cxf.jar app.jar
+ADD target/spring-boot-sample-rs.jar spring-boot-sample-rs.jar
 ENV JAVA_OPTS=""
-ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /spring-boot-sample-rs.jar" ]

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot/README
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/README b/distribution/src/main/release/samples/jax_rs/spring_boot/README
index 4d107b1..36c5ada 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot/README
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot/README
@@ -31,10 +31,10 @@ $ mvn dockerfile:push
 
 Run the container:
 --
-docker run -p 8080:8080 -t ${username}/apachecxf:spring-boot-sample-rs-cxf
+docker run -p 8080:8080 -t ${username}/apachecxf:spring-boot-sample-rs
 --
 
-== Testing the server ==
+= Testing the server =
 
 ---- From the browser ----
 
@@ -46,6 +46,7 @@ http://localhost:8080/services/helloservice/sayHello2/ApacheCxfUser
 
 will display "Hello2 ApacheCxfUser, Welcome to CXF RS Spring Boot World!!!"
 
+
 http://localhost:8080/services/helloservice/swagger.json will return a Swagger JSON
 description of services.
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml
index bc03164..07ae7e2 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot/pom.xml
@@ -9,7 +9,7 @@
         <relativePath>../..</relativePath>
     </parent>
     <groupId>org.apache.cxf.samples</groupId> 
-    <artifactId>spring-boot-sample-rs-cxf</artifactId>
+    <artifactId>spring-boot-sample-rs</artifactId>
     <name>Spring Boot CXF REST Application</name>
     <description>Spring Boot CXF REST Application with Swagger UI</description>
     <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/Dockerfile
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/Dockerfile b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/Dockerfile
new file mode 100644
index 0000000..dd22ae1
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/Dockerfile
@@ -0,0 +1,5 @@
+FROM openjdk:8-jdk-alpine
+VOLUME /tmp
+ADD target/spring-boot-sample-rs-scan-app.jar spring-boot-sample-rs-scan-app.jar
+ENV JAVA_OPTS=""
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /spring-boot-sample-rs-scan-app.jar" ]

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
index 6295e29..d083b16 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
@@ -7,23 +7,43 @@ and deployed in a single JAX-RS endpoint.
 The application registers itself with Eureka Registry.  
 
 The client discovers the client address from the registry and invokes it.
+Make sure that the Eureka registry is started as described in the eureka-registry/README
+before running this application.
 
-The sample uses Maven. It can be built and run from the command line.
+= Starting the server =
 
-To run the client from a command line:
+The sample uses Maven. It can be built and run from the command line using Maven, Java or Docker:
 
-1. If you have not started a eureka-registry application then build and start it 
-first in the eureka-registry folder in a separate terminal window:
+---- With Maven ----
 
 $ mvn spring-boot:run
 
-2. Run the server 
-----
-$ mvn -Pserver
-----
+---- With Java ----
 
-3. Check that the server is deployed:
+$ java -jar target/spring-boot-sample-rs-scan-app.jar
 
+---- With Docker ----
+
+Install Docker, create the demo image:
+--
+$ mvn dockerfile:build
+--
+
+Optional step, push the image. 
+Create a DockerHub id, for example, make this id set to your current ${username}
+--
+$ docker login
+$ mvn dockerfile:push
+--
+
+Run the container:
+--
+docker run -p 8080:8080 --network="host" -t ${username}/apachecxf:spring-boot-sample-rs-scan-app 
+
+= Testing the server =
+
+---- From the browser ----
+ 
 http://localhost:8080/services/helloservice/sayHello/ApacheCxfUser
 
 will display "Hello ApacheCxfUser, Welcome to CXF RS Spring Boot World!!!"
@@ -32,9 +52,12 @@ http://localhost:8080/services/helloservice/sayHello2/ApacheCxfUser
 
 will display "Hello2 ApacheCxfUser, Welcome to CXF RS Spring Boot World!!!"
 
+
+---- From the command line ----
+
 Check client/README on how to run a command line client.
 
-4. Swagger JSON and UI
+= Swagger JSON and UI =
 
 http://localhost:8080/services/helloservice/swagger.json will return a Swagger JSON
 description of services.
@@ -51,7 +74,7 @@ or access it from the CXF Services page:
 (Note - CXF Services page is available by default at the path ending with "/services" - but in this demo
 it has been configured to listen at "/info")
 
-5. System metrics and health checks
+= System metrics and health checks =
 
 http://localhost:8080/system/metrics 
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
index eab8bf2..8b93dd7 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
@@ -8,7 +8,7 @@
         <version>3.2.0-SNAPSHOT</version>
         <relativePath>../../..</relativePath>
     </parent>
-    <artifactId>spring-boot-sample-rs-cxf-scan-app</artifactId>
+    <artifactId>spring-boot-sample-rs-scan-app</artifactId>
     <name>Spring Boot CXF REST Scan Application</name>
     <description>Spring Boot CXF REST Scan Application</description>
     <dependencyManagement>
@@ -50,7 +50,7 @@
             <artifactId>spring-cloud-starter-eureka</artifactId>
             <version>${spring.cloud.eureka.version}</version>
         </dependency>
-        <!-- Actuator Endpoints -->
+        <!-- Actuator  Endpoints -->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-actuator</artifactId>
@@ -65,6 +65,44 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring.boot.version}</version>
+                <configuration>
+                    <mainClass>sample.rs.service.SampleRestApplication</mainClass>
+                </configuration>
+                <executions>
+                   <execution>
+                      <goals>
+                          <goal>repackage</goal>
+                       </goals>
+                   </execution>
+                </executions>
+            </plugin>
+            <plugin>
+              <groupId>com.spotify</groupId>
+              <artifactId>dockerfile-maven-plugin</artifactId>
+              <version>1.3.4</version>
+              <executions>
+               <execution>
+                <id>default</id>
+                <goals>
+                  <goal>build</goal>
+                  <goal>push</goal>
+                </goals>
+               </execution>
+              </executions>
+              <configuration>
+                <repository>${user.name}/apachecxf</repository>
+                <tag>${project.artifactId}</tag>
+              </configuration>
+            </plugin>
+        </plugins>
+    </build>
     <profiles>
         <profile>
             <id>server</id>
@@ -72,13 +110,14 @@
                 <activeByDefault>true</activeByDefault>
             </activation>
             <build>
+                <finalName>${project.artifactId}</finalName> 
                 <defaultGoal>spring-boot:run</defaultGoal>
                 <plugins>
-                    <plugin>
-                        <groupId>org.springframework.boot</groupId>
-                        <artifactId>spring-boot-maven-plugin</artifactId>
-                        <version>${spring.boot.version}</version>
-                    </plugin>
+                   <plugin>
+                     <groupId>org.springframework.boot</groupId>
+                     <artifactId>spring-boot-maven-plugin</artifactId>
+                     <version>${spring.boot.version}</version>
+                   </plugin>
                 </plugins>
             </build>
         </profile>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
index e5f80b3..6ca143d 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
@@ -16,7 +16,7 @@ eureka:
   client:
     registerWithEureka: true
     serviceUrl:
-      defaultZone: http://127.0.0.1:8761/eureka/
+      defaultZone: ${EUREKA_SERVER_URI:http://${EUREKA_SERVER_USER:}:${EUREKA_SERVER_PASS:}@127.0.0.1:8761}/eureka/
   instance:
     statusPageUrlPath: /services/helloservice/info
     healthCheckUrlPath: /system/health

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/client/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/client/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/client/pom.xml
index 40ad3c4..279af55 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/client/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/client/pom.xml
@@ -8,7 +8,7 @@
         <version>3.2.0-SNAPSHOT</version>
         <relativePath>../../..</relativePath>
     </parent>
-    <artifactId>spring-boot-sample-rs-cxf-scan-client</artifactId>
+    <artifactId>spring-boot-sample-rs-scan-client</artifactId>
     <name>Spring Boot CXF REST Scan Application Client</name>
     <description>Spring Boot CXF REST Scan Application Client</description>
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/Dockerfile
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/Dockerfile b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/Dockerfile
new file mode 100644
index 0000000..03b3ee3
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/Dockerfile
@@ -0,0 +1,6 @@
+FROM openjdk:8-jdk-alpine
+VOLUME /tmp
+ADD target/spring-boot-sample-rs-scan-eureka.jar spring-boot-sample-rs-scan-eureka.jar
+EXPOSE 8761
+ENV JAVA_OPTS=""
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /spring-boot-sample-rs-scan-eureka.jar" ]

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/README
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/README b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/README
index 7da21aa..1f6c62d 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/README
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/README
@@ -3,11 +3,38 @@
 This sample project shows how to start Eureka Registry.  
 
 
-Run the registry application:
- 
-----
+= Starting the registry =
+
+The sample uses Maven. It can be built and run from the command line using Maven, Java or Docker:
+
+---- With Maven ----
+
 $ mvn spring-boot:run
-----
+
+---- With Java ----
+
+$ java -jar target/spring-boot-sample-rs-scan-eureka.jar
+
+---- With Docker ----
+
+Install Docker, create the demo image:
+--
+$ mvn dockerfile:build
+--
+
+Optional step, push the image. 
+Create a DockerHub id, for example, make this id set to your current ${username}
+--
+$ docker login
+$ mvn dockerfile:push
+--
+
+Run the container:
+--
+docker run -p 8080:8080 -t ${username}/apachecxf:spring-boot-sample-rs-scan-eureka
+--
+
+= Testing the registry =
 
 Check the registry is live with typing "http://localhost:8761/eureka/apps" in a browser.
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/ce3de8e3/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/pom.xml b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/pom.xml
index d61b31b..e0b7dc5 100644
--- a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/eureka-registry/pom.xml
@@ -8,7 +8,7 @@
         <version>3.2.0-SNAPSHOT</version>
         <relativePath>../../..</relativePath>
     </parent>
-    <artifactId>eureka-registry-for-cxf</artifactId>
+    <artifactId>spring-boot-sample-rs-scan-eureka</artifactId>
     <name>Eureka Registry for CXF SpringBoot demos</name>
     <description>Eureka Registry for CXF SpringBoot demos</description>
     <properties>
@@ -40,11 +40,37 @@
 
 
     <build>
+        <finalName>${project.artifactId}</finalName>
         <plugins>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <version>${spring.boot.version}</version>
+                <executions>
+                   <execution>
+                      <goals>
+                          <goal>repackage</goal>
+                       </goals>
+                   </execution>
+                </executions>
+            </plugin>
+            <plugin>
+              <groupId>com.spotify</groupId>
+              <artifactId>dockerfile-maven-plugin</artifactId>
+              <version>1.3.4</version>
+              <executions>
+               <execution>
+                <id>default</id>
+                <goals>
+                  <goal>build</goal>
+                  <goal>push</goal>
+                </goals>
+               </execution>
+              </executions>
+              <configuration>
+                <repository>${user.name}/apachecxf</repository>
+                <tag>${project.artifactId}</tag>
+              </configuration>
             </plugin>
         </plugins>
     </build>