Mohamed Taboubi
Mohamed Taboubi

Reputation: 7021

Copy a folder to Pivotal Cloud Foundry

I m running a jar application that uses some resources folder that needs to be in the same path as the jar:

here is an example of my folder how it uses to be :

    $ ls
__files  mappings  wiremock-standalone-2.24.0.jar

I'm able to push the jar file using

cf push wiremock-standalone-2.24.0.jar

But not able to push the two folders mappings and __files to pcf.

When I do :

cf push wiremock/__files

Ittries to create an app named wiremock/__files:

    Getting app info...
Creating app with these attributes...
+ name:       wiremock/__files
  path:       /tmp/build/2985dd2f

What is the command line I should use ?

Upvotes: 2

Views: 2019

Answers (3)

Doug Baughman
Doug Baughman

Reputation: 39

As suggested by @Alex Rashkov, I added the files to the jar and that worked perfectly.

My problem was exactly the same as in the original question, I want to deploy wiremock to PCF with pre-configured mappings, so I did the following:

  • Started the wiremock server locally and defined the required mappings via the REST api (/__admin/mappings/import or /__admin/mappings/new)
  • Saved the mappings (__admin/mappings/save)
  • Now all the mappings will appear as files in the mappings directory
  • Add the mappings directory to the jar file (jar -uf wiremock-standalone-2.24.0.jar mappings). I just updated the downloaded jar file directly, but I can see where you might want to update a copy as suggested above.
  • push the updated jar file to PCF (java_buildpack). The wiremock server running in PCF will see the mappings in the mappings folder and have those predefined.

Thanks @Alex Rashkov for the tip!

Upvotes: 1

Alex Rashkov
Alex Rashkov

Reputation: 10015

What you could do is add all missing files to your JAR package:

cp wiremock-standalone-2.24.0.jar wiremock-standalone-2.24.0-fat.jar
jar uf wiremock-standalone-2.24.0-fat.jar ./lib

Than your command will be exactly the same all you have to do is point to the new resources inside the Java app.

Upvotes: 3

Scott Frederick
Scott Frederick

Reputation: 5125

cf push is used to deploy an application to a container. Anything that is deployed with cf push is expected to be an executable app. Even if you were able to cf push wiremock/__files successfully, the files would end up in a different container and inaccessible from the container created for cf push wiremock-standalone-2.24.0.jar.

It sounds like you need the jar file, __files, and mappings to all be in the same container. To make this happen, you'll need to bundle them all into an archive and cf push them together.

Upvotes: 1

Related Questions