Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENDOC-575 Update the jhipster tutorial for Docker-based format in Ent… #581

Merged
merged 6 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,76 @@ sidebarDepth: 2

## Overview

This tutorial describes how to use the Entando Component Generator (ECG) to create microservices and micro frontends for deployment to the [Entando Component Repository](../../../docs/compose/local-hub-overview.md) and Entando Applications. The ECG is powered by [JHipster](https://www.jhipster.tech/) and leverages the Entando Blueprint.
This tutorial describes how to use the Entando Component Generator (ECG) to create microservices and micro frontends for deployment to the [Local Hub](../../../docs/compose/local-hub-overview.md) of an Entando Application or a shared [Entando Hub](../../../docs/getting-started/landing-page.md#entando.hub). The ECG is powered by [JHipster](https://www.jhipster.tech/) and leverages the Entando Blueprint.

![Entando Component Generator](./img/component-gen-flow.png)
The [general development process](../../../docs/curate/bundle-details.md#bundle-development-process) is:

The general flow of component generation is:

1. Run the Entando Blueprint to create your components (Spring Boot microservice and optionally React micro frontends)
2. Customize and enhance your generated code
3. Build an Entando Bundle from your components
4. Deploy a [custom resource](../../../docs/consume/custom-resources.md) for your bundle into Kubernetes
5. Install your Entando Bundle into your Entando Application(s)
1. Set up a new bundle project
2. Run the Entando Blueprint to create your components (Spring Boot microservice and optionally React micro frontends)
3. Configure the bundle project to wire together the components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove period (no punctuation)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking that since these are not instructions but a layout of the process, they should be proper sentences. For a moment, thought they were instructions and was thinking, what, this is all I get for instructions?!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have been leaving bullets or numbered lists outlining a process unpunctuated on other pages. i think either way is fine, but suggested unpunctuated in this case because #3 is the only line item with a period, so changing it to align with the rest would be less effort than changing all the others to match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shifted the direction here since we have better docs on the overall process now.

4. Build an Entando Bundle from your components
5. Deploy a [custom resource](../../../docs/consume/custom-resources.md) for your bundle into Kubernetes
6. Install your Entando Bundle into your Entando Application(s)

## Prerequisites
Use the [Entando CLI](../../../docs/getting-started/entando-cli.md#check-the-environment) to verify environmental dependencies (e.g. Java, npm, git, JHipster, Entando Blueprint).
* Use the [Entando CLI](../../../docs/getting-started/entando-cli.md#check-the-environment) to verify environmental dependencies (e.g. Java, npm, git, JHipster, Entando Blueprint).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing wrong with this, but we've shifted to slight variations of the following:

Prerequisites

``` sh
ent check-env develop
```

## Generate the Project
Create a project with microservices.

1. Setup a new project directory
``` sh
mkdir testProject && cd testProject
```

2. Use `ent jhipster` to generate the project skeleton via the Entando Blueprint
``` sh
ent jhipster --blueprints entando
* This tutorial sets up a bundle with the Docker-based format first introduced with Entando 7.1.

## Set Up a New Bundle Project
1. Create a new bundle project directory. This will add a simple `entando.json` descriptor as a starting point.
```shell
ent bundle init YOUR-PROJECT-NAME
````
2. Change into the project directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

punctuate with a colon

```shell
cd YOUR-PROJECT-NAME
```

3. This triggers a project initialization prompt. Enter "Yes" in response.

`The project dir doesn't seem to be initialized, should I do it now?` (**Yes**)

4. Enter "Yes" when prompted with the following overwrite to resolve the conflict:

`Overwrite .gitignore?`
## Generate the Components
1. Use the entando cli to add a microservice to the project. This step creates the basic configuration and then the Entando Blueprint generates the service code in the following steps.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entando CLI

would save the note on the service code for the step(s) that generate it; possible rephrase to "Use the Entando CLI to add a basic microservice configuration to the project:"

```shell
ent bundle ms add conference-ms --stack=spring-boot
```
2. Change to the microservice directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe replace "change to" with "shell into" or "navigate to"; punctuate with :

```shell
cd microservices/conference-ms
```

5. You'll be presented with a series of additional prompts pertaining to project configuration. These are echoed below, with the base values for this tutorial in parentheses. Input your preferences, except where a required entry is identified in **bold**. Note that the `Enter` key will select the default option.
3. Use the Entando Blueprint (powered by JHipster) to generate the `conference-ms` microservice.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

punctuate with :

```shell
ent jhipster --blueprints=entando
```

4. You'll be presented with a series of prompts pertaining to service generation. These are echoed below, with the base values for this tutorial in parentheses. Input your preferences, except where a required entry is identified in **bold**. Note that the `Enter` key will select the default option.

- `Please provide the project name:` (Up to you)

- `What is the base name of your application?` (Up to you)
- `As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts.` (8081)
- `What is your default Java package name?` (Up to you)
- `Which *type* of database would you like to use?` (SQL)
- If no database is selected you'll be building a stateless microservice, which is a valid choice, but the rest of this tutorial won't work.
- `Which *production* database would you like to use?` (PostgreSQL or MySQL)
- `Which *production* database would you like to use?` (PostgreSQL)
- `Which *development* database would you like to use?` (H2 with disk-based persistence)
- `Which cache do you want to use? (Spring cache abstraction)` (Caffeine (local cache, for a single node))
- `Do you want to use Hibernate 2nd level cache?` (Yes)
- `Which other technologies would you like to use?` (**Don't select any other technologies**)
- `Which BE dependencies do you want to use?` (Dependencies maintained by Entando (entando/entando-bundle-bom))
- `What name would you give to the bundle to share on an Entando Component Repository?` (Up to you)
- `Which is the organization name to use when publishing the docker image?` (**Enter the name of the organization where you are going to push your Docker image. If you're using your personal Docker hub account enter your username.**) <-- this can be changed later as needed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why were these two items removed? I still get them

- `Would you like to generate micro frontends when creating entities?` (Always)
- `Would you like to enable internationalization support` (Up to you)
- `Please choose the native language of the application` (Up to you)
- `Besides JUnit and Jest, which testing frameworks would you like to use?` (Up to you)
- `Would you like to install other generators from the JHipster Marketplace?` (No)

6. Next, add an Entity to your microservice and create the corresponding micro frontends. In this tutorial, `Conference` is the name of the entity that will be added to the application.
5. Enter "Yes" when prompted with the following overwrite to resolve the conflict:

`Overwrite .gitignore?`

6. Add an Entity to your microservice and create the corresponding micro frontends. In this tutorial, `Conference` is the name of the entity that will be added to the application.

``` sh
```shell
ent jhipster entity Conference
```

Expand All @@ -98,23 +102,56 @@ ent jhipster entity Conference
- `Do you want pagination and sorting on your entity?` (Yes, with infinite scroll)
- (If you chose to be prompted to generate micro frontends) `Do you want to generate micro frontends?` (Up to you)


8. Affirm each overwrite prompt (echoed below) to resolve conflicts as the Blueprint generates controllers, repositories, services and micro frontends for your entity. **Note: Enter "a" in response to the initial prompt to authorize all overwrites to existing files with the necessary configuration changes.**
- `Overwrite src/main/resources/config/liquibase/master.xml?`
8. Affirm each overwrite prompt to resolve conflicts as the Blueprint generates controllers, repositories, services and micro frontends for your entity. **Note: Enter "a" in response to the initial prompt to authorize all overwrites to existing files with the necessary configuration changes.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would rephrase last sentence to "...authorize all necessary configuration changes to the existing files."


- `Overwrite package.json?`
- `Overwrite bundle/descriptor.yaml?`
- `Overwrite bundle/plugins/jhipster-plugin.yaml?`
- `Overwrite src/main/resources/config/liquibase/master.xml?`
- `Overwrite src/main/java/com/mycompany/myapp/config/CacheConfiguration.java?`

You have now generated an Entando project, including a Spring Boot microservice with database integration and React-based micro frontends.
You have now generated a Spring Boot microservice with database integration and React-based micro frontends.

### Project Structure
* ```/src/main/docker``` contains Docker files to help with local development environments.
### Output
* ```/src/main/java``` and ```src/main/resources``` contain the microservice codebase and configuration.
* ```/ui``` holds the React-based micro frontends. By default, JHipster generates 3 MFEs per entity to contain the details, form, and table.
* ```/bundle``` is used to assemble the project code into an Entando Bundle.
* ```/src/main/docker``` contains Docker files to help with local development environments.

Next you'll move the `/ui` and `/src/main/docker` files into the standard Entando bundle locations and then wire the MFEs and microservice together.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next,

Entando Bundle locations or bundle locations (actually, "into a folder/directory" vs "to a location")

a little odd to abbreviate with MFE but not MS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

into the standard Entando Bundle locations << seems right to me

MFE & MS should both be plural.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

singular or plural, it's odd to abbreviate one and not the other, and MSs looks funny

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworded slightly. There's only a single microservice in this bundle. In theory you can wire a single MFE to multiple microservices but in this case we have 3 MFEs pointing to that one service.


## Finish configuring the bundle project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

header seems to deviate from use of all caps

1. Change back to the root directory of your project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment wrt "change"

punctuate with :

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think change is fine, especially since cd is change directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"change back" sounds a little off out of this context, but given that, yes, it works

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified this one. In other tutorials we dropped the cd commands and just led with "In x directory".

```shell
cd ../..
```
2. Edit the `entando.json` and update `microservices/conference-ms` to set the healthCheckPath and dbms.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DBMS

punctuate with :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I back-ticked these since lowercase dbms is the actual field name in the entando.json

```json
"healthCheckPath":"/management/health",
"dbms":"postgresql"
```

3. Move the generated `conference-table` MFE into the correct location in the bundle project. If you chose a different entity name, you'll need to adjust these commands accordingly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to the correct location (into the correct folder)

```shell
ent bundle mfe add conference-table
find microservices/conference-ms/ui/widgets/conference/tableWidget/. -mindepth 1 -maxdepth 1 -exec mv -t microfrontends/conference-table/ -- {} +
```

4. Now add an API claim to connect the `conference-table` MFE to the `conference-ms` microservice. This connection information is stored in the `entando-json`.
```shell
ent bundle api add conference-table conference-api --serviceName=conference-ms --serviceUrl=http://localhost:8081
```

5. Repeat the previous steps for the `conference-details` and `conference-form` MFEs.
```shell
ent bundle mfe add conference-details
ent bundle mfe add conference-form
find microservices/conference-ms/ui/widgets/conference/detailsWidget/. -mindepth 1 -maxdepth 1 -exec mv -t microfrontends/conference-details/ -- {} +
find microservices/conference-ms/ui/widgets/conference/formWidget/. -mindepth 1 -maxdepth 1 -exec mv -t microfrontends/conference-form/ -- {} +
ent bundle api add conference-details conference-api --serviceName=conference-ms --serviceUrl=http://localhost:8081
ent bundle api add conference-form conference-api --serviceName=conference-ms --serviceUrl=http://localhost:8081
```

6. Finally, move the auxiliary services into place in the bundle project and enable the keycloak service for local tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refine "into place" to be clarified/precise

Keycloak

punctuate with :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back-ticked keycloak since the service name is lowercase.

```shell
mv microservices/conference-ms/src/main/docker/* svc/
ent bundle svc enable keycloak
```

## Next Steps
Follow one of the links below to learn how to assemble and run a bundle locally or deploy it.
Expand Down
Binary file not shown.