Demo instructions for WebSphere on Pivotal Cloud Foundry at SpringOne 2018
These instructions guide you through deploying Spring Boot applications to Open Liberty. Three demos are defined:
- deploying Spring Boot applications directly to Liberty
- producing a Liberty uber jar
- creating Liberty based Docker image.
Branch: git checkout demo1-SpringBootDeploy
- Build the Spring Boot uber jar
git clone https://github.com/barecode/spring-petclinic.gitcd spring-petclinic- Build
./mvnw package - Run
java -jar target/spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar - Browse to
http://localhost:8080/
- Start Liberty
./mvnw io.openliberty.boost:boost-maven-plugin:0.1:start- Browse to
http://localhost:9080/(See Open Liberty welcome page)
- Deploy the Spring Boot uber jar via dropins/spring
vi target/liberty/wlp/usr/servers/BoostServer/server.xml- Add
<feature>springBoot-2.0</feature> mkdir target/liberty/wlp/usr/servers/BoostServer/dropins/springcp target/spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar target/liberty/wlp/usr/servers/BoostServer/dropins/spring- Browse to
http://localhost:9080/(See PetClinic)
- Cleanup
./mvnw io.openliberty.boost:boost-maven-plugin:0.1:stop
Branch: git checkout demo2-libertyUberJar
- Add the following to the end of pom.xml build plugins section:
<plugin> <groupId>io.openliberty.boost</groupId> <artifactId>boost-maven-plugin</artifactId> <version>0.1</version> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin>
- Run
./mvnw clean package - Run the uber jar:
java -jar target/spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar - Browse to
http://localhost:8080/
Branch: git checkout demo3-dockerize
- Add the following to the end of pom.xml build plugins section:
<plugin> <groupId>io.openliberty.boost</groupId> <artifactId>boost-maven-plugin</artifactId> <version>0.1</version> <executions> <execution> <goals> <goal>docker-build</goal> </goals> </execution> </executions> </plugin>
- Run
./mvnw clean install - Run the Docker image:
docker run -p 9080:9080 spring-petclinic - Browse to
http://localhost:9080/
Branch: git checkout demo4-cf-push
Note: due to limitations in Liberty 18.0.0.3 and the Liberty buildpack as of Sept 26, 2018, a work-around for cf push is needed. These steps set up a directory structure called distZip which push a run script and the Liberty uber jar.
- Ensure the package goal is set for the Boost plugin execution goals:
<plugin> <groupId>io.openliberty.boost</groupId> <artifactId>boost-maven-plugin</artifactId> <version>0.1</version> <executions> <execution> <goals> <goal>package</goal> </goals> </execution> </executions> </plugin>
- Run
./mvnw clean package - Copy the jar to
distZip/lib/ - Review the
distZip/bin/run.sh, which uses the known path to Java to run the jar.
#!/bin/sh
CUR_DIR="$(cd $(dirname $0) && pwd)"
/home/vcap/app/.java/jre/bin/java -jar $CUR_DIR/../lib/spring-petclinic-2.0.0.BUILD-SNAPSHOT.jar
- Run
cd distZip - Run
cf push- if using IBM Cloud, you will need to runibmcloud cf push - Browse to the route which Cloud Foundry created
The demo given at Spring One does not use this repository, but a different fork of Spring Initializr. However, the steps taken in the demo work for this Docker image as well. The steps to create a Kubernetes cluster are not repeated here, as those steps will vary from Kubernetes vendor. To show a Spring Boot with Liberty Docker image running on Kubernetes, follow the instructions for your preferred Kubernetes environment.