1

I have created an "enterprise template" Liberty server with an EAR file application requiring a few SQLDB connections. This is working and I am able to cf push this server to the Bluemix environment.

My question is how do I go about packaging the entire content and publish this to Bluemix in ONE action (i.e., they will have an instance of the same application running on Liberty with the same SQLDB table setup).

From my quick browsing of the blogs and Q&A, I have only found articles talking about creating the SQLDB ahead of time, packaging the Liberty runtime as a .zip file, and then using cf push to Bluemix. Because the SQLDB was created ahead of time, the DB connections would work.

So is there a way to package the Liberty server with the SQLDB creation as one entity into perhaps one "buildpack"? If so, can someone guide me on the steps involved? (or articles/blogs, anything would help)

O Wong
  • 31
  • 3
  • Could you specify better what do you mean with 'package the Liberty server with the SQLDB creation as one entity'? Do you want to package the service inside the package to push? If so, it cannot be possible, the package contains all the configuration files, the source/compiled files, the libraries, but no service at all. The services are provided by Bluemix services. More, SQLDB is a light version on DB2 – v.bontempi Dec 03 '15 at 08:17
  • OK, thanks for you comment. I will refine my question better. I have now created a bat/shell script that has "cf" commands that 1) connect to the bluemix 2) login to bluemix 3) create the sqldb 4) run DDL on the just created sqldb (HOW TO DO THIS) 5) cf push the packaged liberty server (zip file) 6) cf bind server to the sqldb instance 6) cf restage. The question is really step 4), how do I run the DDL on the just created sqldb. – O Wong Dec 03 '15 at 16:04
  • @OWong it seems that your SQLDB and Liberty deployment processes should be separate. Do you always need to recreate the SQLDB every time you cf push Liberty? – Andy Guibert Dec 05 '15 at 17:17

2 Answers2

1

You can't do it.

If you want create a script that do all operations in one time, an idea is create a simple job (in java for example) that you can launch in your script.

The job should perform these steps:

  1. connect to sqldb - bluemix service using VCAP_SERVICES (for this step you can see the documentation https://www.ng.bluemix.net/docs/#services/SQLDB/index.html#SQLDB
  2. run DDL (create table, ...) in your little job
  3. close connection
1

Another option is to package a database migration helper (something like Flyway in the application. Then you can invoke it using Java, on application startup (we've had good luck with @singleton @startup EJBs for this pattern). The migration will run when needed, but leave the database alone otherwise. Another advantage of this pattern is you can use the migrations to update the tables of an existing table (as the name suggests).

Holly Cummins
  • 10,767
  • 3
  • 23
  • 25