GithubHelp home page GithubHelp logo

Comments (15)

simonz130 avatar simonz130 commented on June 14, 2024 1

Etan, the repo is public, @saturnism is welcome to comment and contribute.

from cloud-code-samples.

daniel-sanche avatar daniel-sanche commented on June 14, 2024

Do we need to sync the project as a whole with maven? Won't users of these samples be mostly interacting with the container images rather than the local java environment?

Adding a parent pom that connects to all the sub-components seems to be breaking the spirit of microservices, and it could add more confusion to the project (it makes it seem like the services are more tightly coupled than they are)

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

hey @dansanche

Here is what happens, as is, with the project.

  1. open the root java-guestbook app in IntelliJ. Notice the maven modules are not detected:
    image

  2. look at the module setup under Project Structure. Notice the frontend and backend modules are not present. Most importantly, no source roots are found. This means that the java files will not be compiled and treated sources. This is because there is no root pom.xml. IntelliJ does not automatically pick up the submodules' poms.
    image
    image

Note: At this point, you could deploy the application to Kubernetes using the Run Configurations and it will work. This is independent of the fact that the IDE is not aware of the project structure. But any attempt to add or modify code would be like editing a plain text file.
image

  1. To fix this (without modifying the sample), you can manually add each submodule pom to the maven structure of the project. We would need to document this for users.
    image
    image
    image

Adding a parent pom that connects to all the sub-components seems to be breaking the spirit of microservices

While I see your point here, the sample in its current state has a skaffold configuration that runs both microservices at the same time. Presumably the user would want to open the root guestbook app and have a view of both services in the IDE. If the user only wanted to deal with a single microservice, they could load only the subproject into their IDE and things would compile correctly - however, we currently do not have the ability to load a skaffold.yaml that lives outside of the project root (in this case the skaffold.yaml would live in a parent directory outside of the project).

I guess this ultimately depends on what we are trying to present the user: a multimodule project with a couple services, or independent microservices developed independently.

Maybe @saturnism has some input on a canonical setup for a simple 2 service guestbook app with a frontend and a backend?

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

@dansanche / @simonz130 could you give @saturnism (Ray) access to this repo if he doesn't aleady? He may have some valuable input on the java projects.

from cloud-code-samples.

daniel-sanche avatar daniel-sanche commented on June 14, 2024

That's surprising that IntelliJ won't catch Java errors without the root pom file. Since it seems like IntelliJ requires rigid project structure, would it even support an app made up of many microservices written in different languages? Or would that break the IDEs expectations like this? I'll probably have to experiment with IntelliJ before I can comment more

In general, adding a root pom that references the others wouldn't be the end of the world, but it could be confusing to new users. I'd prefer if all language-specific files were contained completely in the directory for the service. But we could explain the issue with a comment in the file if we really need to

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

That's surprising that IntelliJ won't catch Java errors without the root pom file

Yeah thats mainly coming from the module screenshot that I showed above. There are no source roots defined, therefore IntelliJ is not treating any of the files as Java files.

Adding a root pom would work. Although this is a bit tricky given the Dockerfiles in each submodule which would need access to the parent pom (which is outside of the Docker context itself).

The other option, if adding a parent pom, is to update Skaffold to use Jib and get rid of the Dockerfiles.

from cloud-code-samples.

simonz130 avatar simonz130 commented on June 14, 2024

I am not comfortable with using Jib for Java and docker files for all the rest. Developers who might be interested in creating microservices in different languages will find it a bit confusing.
Also, parent pom sounds like a stop gap to address IntelliJ issues.

Let's see if Ray has ideas on this.

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

That's fine. In the meantime, do you want to tackle adding a parent pom?

from cloud-code-samples.

saturnism avatar saturnism commented on June 14, 2024

+1 to have a parent pom. the original (simpler) was here: https://github.com/saturnism/helloworld-java-springboot.

We should start off simple w/o little dependency as possible.

from cloud-code-samples.

saturnism avatar saturnism commented on June 14, 2024

i noticed that the current sample uses a Dockerfile. For Java, we should use Jib, and also a newer version of OpenJDK version (adoptopenjdk:openjdk8)

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

@simonz130 given what Ray suggested, are you ok making these changes? I'll still go ahead and instruct tech writer to use the guestbook sample in the docs since at least the parent pom issue will get resolved. I was considering falling back to helloworld depending on how quickly we can resolve this.

from cloud-code-samples.

simonz130 avatar simonz130 commented on June 14, 2024

We wanted the samples to be consistent across different languages. This include working with docker files. How Jib plays with Skaffold? We never tested it and I'm not comfortable to make this change in the last minute.

As to root pom - we might have to do it as I don't see anything better we can do for now.
@dansanche - are you OK with adding root pom?

from cloud-code-samples.

daniel-sanche avatar daniel-sanche commented on June 14, 2024

Yeah, it seems like we probably need to add the pom to support IntelliJ at this point. I threw togther a PR with simple parent pom here #35

I'm not too familiar with intelliJ though, so idk if this pom will work automatically with the intended work flow. Someone more familiar should try it out and give feedback/fixes. (I seemed to get a couple "cannot resolve symbol" issues, but I think that's because I didn't set up the IDE properly last time I used it)

from cloud-code-samples.

etanshaul avatar etanshaul commented on June 14, 2024

The parent pom added in the PR works now. I'd suggest we iterate on the samples to introduce Jib for the Java apps as Ray suggested. We can do this later after v1 and I can help answer any Jib related concerns.

from cloud-code-samples.

simonz130 avatar simonz130 commented on June 14, 2024

OK, sounds good. I'm closing this issue for now as Dan's PR was merged.

from cloud-code-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.