Vaadin app deployment on GCP

Hi, I’m trying to deploy a vaadin app on google cloud platform.
The app runs fine but I’m getting an error at deployment.
I followed this tutorial for the deployment : https://vaadin.com/learn/tutorials/cloud-deployment/google

(Vaadin version : 14.4.4)

here is the error I’m getting at deployment:

2021-01-01 13:00:48.941 INFO 8 — [ main]
c.v.f.s.VaadinServletContextInitializer : Search for subclasses and classes with annotations took 1 seconds
2021-01-01 13:00:48.948 ERROR 8 — [ main]
o.a.c.c.C.[Tomcat]
.[localhost]
.
[/] : Exception sending context initialized event to listener instance of class [com.vaadin.f
low.spring.VaadinServletContextInitializer$DevModeServletContextListener]

java.lang.IllegalStateException: Failed to determine project directory for dev mode. Directory ‘/’ does not look like a Maven or Gradle project. Ensure that you have run the prepare-fr
ontend Maven goal, which generates ‘flow-build-info.json’, prior to deploying your application

at com.vaadin.flow.server.startup.DevModeInitializer.getBaseDirectoryFallback(DevModeInitializer.java:399) ~[flow-server-2.4.3.jar!/:2.4.3]

    at com.vaadin.flow.server.startup.DevModeInitializer.initDevModeHandler(DevModeInitializer.java:255) ~[flow-server-2.4.3.jar!/:2.4.3]

    at com.vaadin.flow.spring.VaadinServletContextInitializer$DevModeServletContextListener.contextInitialized(VaadinServletContextInitializer.java:369) ~[vaadin-spring-12.3.2.jar!

/:na]

Failed to determine project directory for dev mode.

This part of the message is the key. You should be deploying a production mode build instead of development mode.

See https://vaadin.com/learn/tutorials/cloud-deployment/google#_prepare_the_application

You need to have also the production profile in your pom.xml, see example https://github.com/Mikaelsu/google-demo/blob/master/pom.xml#L164

Thank you Mr Lund. It was in fact a problem with prepare-frontend and production mode because I didn’t set it up in my pom.xml . I got another problem though. My docker image is 750MB, which is crazy because my app is not that big; the only big folder I have is node_modules. Therefore I can not deploy on GCP because its limited at 250MB I think. Maybe I didn’t build it right.

I was actually just testing how much time it will take me to deploy and I will probably have to read more documentation because I encountered a lot of 500 http errors.

the only big folder I have is node_modules.

You do not need that folder in runtime, this folder is used only when application is build. The vaadin maven plugin commands npm to download web component libraries etc. there. The prepare_frontend and build_frontend tasks are related. Those will compose optimized frontend bundle containing only those components used by the application and minify it.

To build the docker file I just ran these commands:

  • mvn install -Pproduction
  • docker build -t -docker .
  • docker run -ti -p 8090:8080 -docker

that are specified in this tutorial : https://vaadin.com/learn/tutorials/docker-container
so I don’t know exactly how to “exclude” the node_modules file.

Same goes for deployment I just run : “mvn package -Pproduction” which generates a Jar in the target folder. Then I deploy that jar.