Search code examples
angularquarkus

Quarkus + Angular in JavaVM not working after deployment


I created a Quarkus app for my backend. In the folder src/main/angular I created an Angular app for my frontend. When I build my Angular app, the files are stored in /src/main/resources/META-INF/resources. Then I start my Quarkus app with mvn clean quarkus:dev and everything works fine. My frontend is accessible and so is the backend.

My problem start when I create an image of the app using JVM to deploy on it Kubernetes. The backend is still accessible, but for the frontend I get a 404. I checked the deployed .jar file and it contains my frontend files.

What am I missing? Is the any special setting that I forgot? Or is there a better approach besides deploying two separate images?


Solution

  • The simplest way to package javascript content with a Quarkus application is to use the Quinoa extension. It saves you the trouble of deciding on a folder structure, handles live reload proxying during development, and also packaging for production (even for native builds).

    To add the extension (assuming maven):

    ./mvnw quarkus:add-extension -Dextensions="io.quarkiverse.quinoa:quarkus-quinoa"
    

    Then put your Angular content in src/main/webui (not META-INF/resources). That should be enough for quarkus dev and a production build to both work. To try your application, visit it on the usual Quarkus port, `http://localhost:8080/'.

    If needed, the application.properties can be configured with the port and folder names, but that's not usually necessary with popular frameworks.