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 :

(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]
[/] : Exception sending context initialized event to listener instance of class [com.vaadin.f

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( ~[flow-server-2.4.3.jar!/:2.4.3]

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

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


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.


You need to have also the production profile in your pom.xml, see example

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 :
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.