Skip to content

Deployment

Martin Večeřa edited this page Jan 6, 2024 · 19 revisions

Quickstart

To quickly start backend including an embedded MongoDB you can follow these steps:

  1. Make sure you have built the backend with mvn install -DskipTests.
  2. Change to the war directory.
  3. Copy settings.xml from the war directory to your Maven home (typically ~/.m2), or copy&paste its content to the relevant parts of your existing settings.xml file.
  4. While still located in the war directory, run mvn wildfly:run -PstartEngine.
  5. To stop the running backend, simply press Ctrl+C.

The rest of this document describes how to use IntelliJ IDEA to quickly deploy the application to WildFly application server during the development process. You will need Ultimate Edition since the features used here are not available in the Community Edition. Most of the steps and principles can be applied to another IDE as well. While deploying the backend to an externally started WildFly server, you also need a standalone MongoDB instance running.

MongoDB Configuration

A local instance of MongoDB is needed when: deploying application to a standalone WildFly server. Separate MongoDB is not needed when: running tests (they span their own embedded MongoDB), when starting backed via Maven (as described above).

You can either use docker or the manual way listed below. For docker, run docker run -itd -p 27017:27017 --name my-mongo mongo. To stop it run docker stop my-mongo. To start it again later with the previous data run docker start my-mongo. To discard it, while stopped run docker rm my-mongo.

Alternative manual way:

  1. Install MongoDB
    1. Go to MongoDB Download Center
    2. Download the latest MongoDB for your platform
    3. Install MongoDB according to the instructions on the website
  2. Run MongoDB
    1. Run mongod in the command line
    2. Keep it running during the development process

You can use MongoDB plugin for IntelliJ IDEA to see the actual content of the database.

Importing the project

Prerequisite: Installed JDK 21.

After importing the Maven project open File -> Project Structure... and check the following:

  1. SDKs has JDK 21 added.
  2. Project has Projeck SDK set to version 21 and Project language level to 20.
  3. In Modules all modules' language level set to 20.

WildFly Configuration

In order to be able to deploy the application by one click, you will need to configure WildFly in your IDE:

  1. Prepare WildFly application server
    1. Open a command line in the engine folder
    2. Run mvn clean install -DskipTests
    3. Go to war/target folder
    4. Copy wildfly-30.0.0.Final to some other location (preferably outside of the project)
  2. Enable JBoss Integration plugin
    1. Open IntelliJ IDEA
    2. Go to File -> Settings -> Plugins or IntelliJ IDEA -> Settings -> Plugins on MacOS
    3. Find and check WildFly
    4. Apply the changes and restart the IDE
  3. Add a new application server
    1. Go to File -> Settings -> Build, Execution, Deployment -> Application Servers
    2. Click on a green plus button (Add application server)
    3. Select the path to your copy of wildfly-30.0.0.Final directory
    4. Save the changes
  4. Modify Run/Debug Configurations
    1. Go to Run -> Edit Configurations...
    2. Click on the plus button above the list on the left
    3. Select JBoss/WildFly Server -> Local
    4. Choose the previously added application server
    5. Change the URL to http://localhost:8080/lumeer-engine
    6. Configure VM options to: -Djboss.server.default.config=standalone.xml -XX:+ExitOnOutOfMemoryError -Xmx1g -Xms1g --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED
    7. On the Deployment tab add new artifact engine-war:war exploded
    8. On the Startup/Connection tab set environment properties SKIP_SECURITY=true, SKIP_LIMITS=true, SKIP_PAYMENTS=true, ADMIN_USER_EMAILS=<your user email>
    9. Save the settings

Application Deployment

After you have successfully configured both MongoDB and WildFly, you can run the application from your IDE:

  1. Deploy the application
    1. Select previously created WildFly 30 configuration in the top right corner of the screen.
    2. Click run button and wait for the deployment
    3. Access some REST endpoint from your browser
  2. Redeploy the application
    1. Make some changes in the code
    2. Click Update application button in the left panel on the bottom of the screen
    3. Choose if you want to restart the whole server or just redeploy the application

Web UI Deployment

See web-ui README.

Clone this wiki locally