Development Usage
Please note! This Docker setup is not for production!
Contents:
Quickstart
See Quickstart.
Intro
Assuming you have Docker, Docker Desktop, Moby or some remote Docker host configured, up and running from here on. Also assuming you have Java and Maven installed, as you are at least about to develop code changes.
To test drive these local changes to the Dataverse codebase in a containerized application server (and avoid the setup described in Development Environment), you must a) build the application and b) run it in addition to the necessary dependencies. (Which might involve building a new local version of the Config Baker Image.)
Building
To build the application and config baker image, run the following command:
mvn -Pct clean package
Once this is done, you will see images gdcc/dataverse:unstable
and gdcc/configbaker:unstable
available in your
Docker cache.
Note: This will skip any unit tests. If you have built the code before for testing, etc. you might omit the
clean
to avoid recompiling.
Note: Also we have a docker-compose-dev.yml
file, it’s currently not possible to build the images without
invoking Maven. This might change in the future.
Running
After building the app and config baker image containing your local changes to the Dataverse application, you want to run it together with all dependencies. There are four ways to do this (commands executed at root of project directory):
Using Maven |
Using Compose |
|
---|---|---|
In foreground |
|
|
In background |
|
|
Both ways have their pros and cons:
In case you want to concatenate building and running, here’s a cheatsheet for you:
Once all containers have been started, you can check if the application was deployed correctly by checking the version at http://localhost:8080/api/info/version or watch the logs.
Note: To stop all containers you started in background, invoke mvn -Pct docker:stop
or
docker compose -f docker-compose-dev.yml down
.
Check that you can log in to http://localhost:8080 using user dataverseAdmin
and password admin1
.
You can also access the Payara Admin Console if needed, which is available at http://localhost:4848. To log in, use
user admin
and password admin
. As a reminder, the application container is for development use only, so we
are exposing the admin console for testing purposes. In a production environment, it may be more convenient to leave
this console unopened.
Note that data is persisted in ./docker-dev-volumes
in the root of the Git repo. For a clean start, you should
remove this directory before running the mvn
commands above.
Viewing Logs
In case you started containers in background mode (see Running), you can use the following commands to view and/or watch logs from the containers.
The safe bet for any running container’s logs is to lookup the container name via docker ps
and use it in
docker logs <name>
. You can tail logs by adding -n
and follow them by adding -f
(just like tail
cmd).
See docker logs --help
for more.
Alternatives:
In case you used Maven for running, you may use
mvn -Pct docker:logs -Ddocker.filter=<service name>
.If you used Docker Compose for running, you may use
docker compose -f docker-compose-dev.yml logs <service name>
. Options are the same.
Redeploying
Rebuild and Running Images
The safest way to redeploy code is to stop the running containers (with Ctrl-c if you started them in the foreground) and then build and run them again with mvn -Pct clean package docker:run
.
IntelliJ IDEA Ultimate and Payara Platform Tools
If you have IntelliJ IDEA Ultimate (note that free educational licenses are available), you can install Payara Platform Tools which can dramatically improve your feedback loop when iterating on code.
The following steps are suggested:
Go to the Payara admin console (either at https://localhost:4848 or http://localhost:4849) and undeploy the dataverse application under “Applications”.
Install Payara Platform Tools.
Under “Server”:
Click “Run” then “Edit Configurations”.
Click the plus sign and scroll down to Payara Server and click “Remote”.
For “Name” put “Payara in Docker” or something reasonable.
Under “Application server” select a local directory that has the same version of Payara used in the container. This should match the version of Payara mentioned in the Installation Guide under Payara.
Change “Admin Server Port” to 4849.
For username, put “admin”.
For password, put “admin”.
Under “Deployment”:
Click the plus button and clien “Artifact” then “dataverse:war”.
Under “Startup/Connection”:
Click “Debug” and change the port to 9009.
Click “Run” and then “Debug Payara in Docker”. This initial deployment will take some time.
Go to http://localhost:8080/api/info/version and make sure the API is responding.
Edit
Info.java
and make a small change to the/api/info/version
code.Click “Run” then “Debugging Actions” then “Reload Changed Classes”. The deployment should only take a few seconds.
Go to http://localhost:8080/api/info/version and verify the change you made.
Using a Debugger
The Application Base Image enables usage of the Java Debugging Wire Protocol
for remote debugging if you set ENABLE_JDWP=1
as environment variable for the application container.
The default configuration when executing containers with the commands listed at Running already enables this.
There are a lot of tutorials how to connect your IDE’s debugger to a remote endpoint. Please use localhost:9009
as the endpoint. Here are links to the most common IDEs docs on remote debugging:
Eclipse,
IntelliJ
Building Your Own Base Image
If you find yourself tasked with upgrading Payara, you will need to create your own base image before running the Quickstart. For instructions, see Application Base Image.