arun-gupta / couchbase-javaee

Couchbase Java EE Application
34 stars 34 forks source link

Add a new profile to deploy to Payara Fish #7

Open arun-gupta opened 8 years ago

arun-gupta commented 8 years ago

Possibly @mikecroft can help

mikecroft commented 8 years ago

Sure, happy to help out! I'm not that familiar with Maven, but I'll see what I can come up with

OndroMih commented 8 years ago

Hi @arun-gupta, @mikecroft, I followed your communication over Twitter and found this issue to be an interesting exercise to play with docker and payara. It seems that with normal payara distribution, the standard glassfish maven plugin can be used as is (although it requires local installation of glassfish or payara with asadmin command).

With payara-micro, it should be enough to copy artifact into the docker instance. I will look into it later too. I think the best approach would be to mount a local folder as a docker volume, link it to payara deployment dir inside the docker, and then only copy the artifact to the local folder in order to deploy.

arun-gupta commented 8 years ago

@OndrejM thanks for contributing.

Requiring a local and manual install restricts the usability of this sample. Can you look at http://lauraliparulo.altervista.org/glassfish-4-0-hello-world-application-with-maven-3/ and see if no local installs are required?

OndroMih commented 8 years ago

Hi Arun, I am also not happy about it but this is the way how the glassfish maven plugin is implemented. It is simply a wrapper around asadmin command that exists in the server installation.

Another option is deploying asynchronously by copying the file over to the deployment directory inside docket. This could be done even with payara-micro, which has half the size of standard Payara image. Should I give it a try? Would that be a viable option?

----- Pôvodná správa ----- Od: "Arun Gupta" notifications@github.com Odoslané: ‎7.‎12.‎2015 21:12 Komu: "arun-gupta/couchbase-javaee" couchbase-javaee@noreply.github.com Kópia: "Ondrej Mihályi" ondrej.mihalyi@gmail.com Predmet: Re: [couchbase-javaee] Add a new profile to deploy to Payara Fish(#7)

@OndrejM thanks for contributing. Requiring a local and manual install restricts the usability of this sample. Can you look at http://lauraliparulo.altervista.org/glassfish-4-0-hello-world-application-with-maven-3/ and see if no local installs are required? — Reply to this email directly or view it on GitHub.

arun-gupta commented 8 years ago

@OndrejM https://maven-glassfish-plugin.java.net/usage.html does not seem to mention that GlassFish/Payara download is required. Mounting a local directory again introduces a local dependency. Any version of Payara where this application can be deployed will work.

OndroMih commented 8 years ago

@arun-gupta, the usage site does not mention it, but path to local glassfish installation is a required parameter to the deploy goal: https://maven-glassfish-plugin.java.net/deploy-mojo.html#glassfishDirectory

arun-gupta commented 8 years ago

@OndrejM that is pretty lame! I don't expect glassfish-maven-plugin to be fixed in the near future given the current state at Oracle. Wondering if @mikecroft or @smillidge have any suggestions?

OndroMih commented 8 years ago

The jar file, which is wrapped by asadmin script, is available in maven: http://search.maven.org/#artifactdetails|org.glassfish.main.admin|appserver-cli|4.1.1|glassfish-jar. It should not be much work to use it directly to deploy to Glassfish/Payara, instead of the maven plugin. Or even to patch maven plugin to use the JAR from maven central instead of from local glassfish installation.

mikecroft commented 8 years ago

Not being familiar with Maven, I'm not sure exactly what you can bend it to do, but you could always deploy via the REST api. A cURL POST should work like in this example: http://blogs.steeplesoft.com/posts/2011/deploying-applications-to-glassfish-using-curl.html

arun-gupta commented 8 years ago

@mikecroft cURL would certainly be awesome. Do you have docs on how to deploy to Payara using REST?

mikecroft commented 8 years ago

No specific Payara docs, but any GlassFish docs will still be valid. So if you go to https://localhost:4848/management/domain/applications/deploy you'll get a basic HTML form wrapper for the REST interface.

The only required property is id, which is indicated by the asterisk next to it. Unintuitively, id in this case means the path to the WAR you want to POST and deploy. You'll probably also want to target it to the default server as well so, based on the example in that blog, you'd have something like this:

curl -s -S \
    -H 'Accept: application/json' -X POST \
    -H 'X-Requested-By: dummy' \
    -F id=@/path/to/application.war \
    -F target=server \
    -F force=true \
    http://localhost:4848/management/domain/applications/application
OndroMih commented 8 years ago

Glassfish documentation about REST administration interface can be found in this PDF https://glassfish.java.net/docs/4.0/administration-guide.pdf - section Using REST Interfaces to Administer GlassFish Server. But it is rather generic, you would need to know the resources you need to modify. In this case, the resource is to deploy applications is applications/application. Operations on resources are not documented in PDF, but can be retrieved from running server via GET method in JSON format - methods attribute in the JSON provides all available methods and attributes (the way how to retrieve this information is documented in the PDF).

OndroMih commented 8 years ago

Hi @arun-gupta, I managed t use cargo maven plugin to deploy to Payara without the requirement of local Payara installation. The cargo maven plugin uses JSR88 API present in deployment-client artefact, which is available in maven central. See my pull request https://github.com/arun-gupta/couchbase-javaee/pull/9