I try to run a payara/micro docker image and deploy my application (war file) from the maven target directory.
I use this image: https://hub.docker.com/r/payara/micro
On the page, I'm following the Run from a mounted volume
section.
My shell script (in the root directory) looks like this:
#!/bin/bash
set -eu
mvn clean package
docker run --rm \
-p 8080:8080 \
-v ~/target:/opt/payara/deployments \
payara/micro
But when I run the script no application is deployed to the payara server. I tried to update the line with -v $(pwd)/target:/opt/payara/deployments \
without success and a new empty folder with the name target;C
is created in the root folder alongside the target folder that contains my war file.
I guess my question is; how can I run payara/micro
container and deploy my target/myapp.war
file to the server from my shell script?
Since I got no answer yet, I want to add my own solution. I kinda cheated but it worked anyway. I combined my shell script with Dockerfile.
I added this Dockerfile into my project root:
FROM payara/micro
COPY target/myapp.war $DEPLOY_DIR
Then, I updated my shell script like this:
#!/bin/bash
set -eu
mvn clean package
docker build -t my-image .
docker run -p 8080:8080 my-image
Now everything works fine.