Install Vaadin 14 App in Production Mode

Hi,

I’m trying to execute mvn install with profile production-mode. Node and yarn both will be installed, but yarn install fails with the following log.

[INFO]
 Scanning for projects...
[INFO]
 
[INFO]
 ------------------< org.mycompany.myapp:frontend >------------------
[INFO]
 Building myapp Frontend 0.3.3-SNAPSHOT
[INFO]
 --------------------------------[ jar ]
---------------------------------
[INFO]
 
[INFO]
 --- maven-clean-plugin:3.1.0:clean (default-clean) @ frontend ---
[INFO]
 Deleting /home/user/git/myapp/frontend/target
[INFO]
 
[INFO]
 --- vaadin-maven-plugin:14.0.7:copy-production-files (default) @ frontend ---
[INFO]
 Copying web application files to '/home/user/git/myapp/frontend/target/frontend'
[INFO]
 
[INFO]
 --- spring-boot-maven-plugin:2.1.4.RELEASE:build-info (build-info) @ frontend ---
[INFO]
 
[INFO]
 --- maven-resources-plugin:3.1.0:resources (default-resources) @ frontend ---
[INFO]
 Using 'UTF-8' encoding to copy filtered resources.
[INFO]
 Copying 1 resource
[INFO]
 Copying 16 resources
[INFO]
 
[INFO]
 --- vaadin-maven-plugin:14.0.7:prepare-frontend (default) @ frontend ---
[INFO]
 Added "name": "@vaadin/flow-deps" line.
[INFO]
 Added "version": "1.0.0" line.
[INFO]
 Added "license": "UNLICENSED" line.
[INFO]
 Updated npm /home/user/git/myapp/frontend/target/frontend/package.json.
[INFO]
 
[INFO]
 --- maven-compiler-plugin:3.8.0:compile (default-compile) @ frontend ---
[INFO]
 Changes detected - recompiling the module!
[INFO]
 Compiling 97 source files to /home/user/git/myapp/frontend/target/classes
[INFO]
 
[INFO]
 --- vaadin-maven-plugin:14.0.7:package-for-production (default) @ frontend ---
[WARNING]
 The translated URL 'frontend://bower_components/vaadin-upload/theme/lumo/vaadin-upload-file.html' has no corresponding file on the filesystem, the file is addressed by path='/home/user/git/myapp/frontend/target/frontend/bower_components/vaadin-upload/theme/lumo/vaadin-upload-file.html'
[INFO]
 Installing node version v10.16.0
[INFO]
 Downloading https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.gz to /home/user/git/myapp/frontend/target/cache/node-v10.16.0-linux-x64.tar.gz
[INFO]
 Downloading via proxy example-proxy{protocol='http', host='XXX.XXX.XXX.XXX', port=80}
[INFO]
 Unpacking /home/user/git/myapp/frontend/target/cache/node-v10.16.0-linux-x64.tar.gz into /home/user/git/myapp/frontend/target/node/tmp
[INFO]
 Copying node binary from /home/user/git/myapp/frontend/target/node/tmp/node-v10.16.0-linux-x64/bin/node to /home/user/git/myapp/frontend/target/node/node
[INFO]
 Installed node locally.
[INFO]
 Installing Yarn version v1.6.0
[INFO]
 Downloading https://github.com/yarnpkg/yarn/releases/download/v1.6.0/yarn-v1.6.0.tar.gz to /home/user/git/myapp/frontend/target/cache/yarn-v1.6.0.tar.gz
[INFO]
 Downloading via proxy example-proxy{protocol='http', host='XXX.XXX.XXX.XXX', port=80}
Okt 01, 2019 4:43:11 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNUNG: Invalid cookie header: "Set-Cookie: has_recent_activity=1; path=/; expires=Tue, 01 Oct 2019 15:43:11 -0000". Invalid 'expires' attribute: Tue, 01 Oct 2019 15:43:11 -0000
Okt 01, 2019 4:43:11 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNUNG: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Sat, 01 Oct 2039 14:43:11 -0000; secure; HttpOnly". Invalid 'expires' attribute: Sat, 01 Oct 2039 14:43:11 -0000
[INFO]
 Unpacking /home/user/git/myapp/frontend/target/cache/yarn-v1.6.0.tar.gz into /home/user/git/myapp/frontend/target/node/yarn
[INFO]
 Installed Yarn locally.
[INFO]
 Installing required frontend tools to '/home/user/git/myapp/frontend/target'
[INFO]
 Running 'yarn install --https-proxy=http://XXX.XXX.XXX.XXX:80 --proxy=http://XXX.XXX.XXX.XXX:80' in /home/user/git/myapp/frontend/target
[INFO]
 yarn install v1.6.0
[ERROR]
 (node:25395) [DEP0005]
 DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[INFO]
 [1/4]
 Resolving packages...
[INFO]
 [2/4]
 Fetching packages...
[INFO]
 [3/4]
 Linking dependencies...
[ERROR]
 warning "polymer-build > polymer-project-config@3.14.0" has incorrect peer dependency "polymer-analyzer@^3.0.0-pre.22".
[INFO]
 [4/4]
 Building fresh packages...
[ERROR]
 error /home/user/git/myapp/frontend/target/node_modules/iltorb: Command failed.
[ERROR]
 Exit code: 127
[ERROR]
 Command: node ./scripts/install.js || node-gyp rebuild
[ERROR]
 Arguments: 
[ERROR]
 Directory: /home/user/git/myapp/frontend/target/node_modules/iltorb
[ERROR]
 Output:
[ERROR]
 info looking for cached prebuild @ /home/user/.npm/_prebuilds/54245c-iltorb-v2.4.3-node-v64-linux-x64.tar.gz
[ERROR]
 http request GET https://github.com/MayhemYDG/iltorb/releases/download/v2.4.3/iltorb-v2.4.3-node-v64-linux-x64.tar.gz
[ERROR]
 WARN install getaddrinfo ENOTFOUND github.com github.com:443
[ERROR]
 /bin/sh: 1: node-gyp: not found
[INFO]
 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
[INFO]
 ------------------------------------------------------------------------
[INFO]
 BUILD FAILURE
[INFO]
 ------------------------------------------------------------------------
[INFO]
 Total time:  50.153 s
[INFO]
 Finished at: 2019-10-01T16:43:22+02:00
[INFO]
 ------------------------------------------------------------------------
[ERROR]
 Failed to execute goal com.vaadin:vaadin-maven-plugin:14.0.7:package-for-production (default) on project frontend: Execution default of goal com.vaadin:vaadin-maven-plugin:14.0.7:package-for-production failed: Failed to install required frontend dependencies: 'yarn install --https-proxy=http://XXX.XXX.XXX.XXX:80 --proxy=http://XXX.XXX.XXX.XXX:80' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

[ERROR]
 
[ERROR]
 To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR]
 Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
 
[ERROR]
 For more information about the errors and possible solutions, please read the following articles:
[ERROR]
 [Help 1]
 http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

The production-mode profile is defined as follows:

	<profiles>
		<profile>
			<!-- Production mode can be activated with either property or profile -->
			<id>production-mode</id>
			<activation>
				<property>
					<name>vaadin.productionMode</name>
				</property>
			</activation>
			<properties>
				<vaadin.productionMode>true</vaadin.productionMode>
			</properties>


			<dependencies>
				<dependency>
					<groupId>com.vaadin</groupId>
					<artifactId>flow-server-production-mode</artifactId>
				</dependency>
			</dependencies>

			<build>
				<plugins>
					<plugin>
						<groupId>com.vaadin</groupId>
						<artifactId>vaadin-maven-plugin</artifactId>
						<version>${vaadin.version}</version>
						<configuration>
							<ignoreMavenProxies>false</ignoreMavenProxies>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>prepare-frontend</goal>
									<goal>build-frontend</goal>
									<goal>copy-production-files</goal>
									<goal>package-for-production</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.springframework.boot</groupId>
						<artifactId>spring-boot-maven-plugin</artifactId>
						<configuration>
							<jvmArguments>-Dvaadin.productionMode</jvmArguments>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

Note that the property ignoreMavenProxies is set to false in order to use the proxy settings defined for maven (see https://github.com/vaadin/flow/issues/5381).

Does anybody know how I can solve this issue.

Thanks in advance!

You should delete the copy-production-files and package-for-production targets. These are only for projects using Bower, V13 or V14 in compatibility mode.

We had the same issue with Vaadin V13 behind corporate proxy when building inside a Docker container (using GitLab CI).

Problem

There is an npm package iltorb, which tries to download prebuilt binaries and if download fails it tries to build binaries from the sources:

Command: node ./scripts/install.js || node-gyp rebuild
  1. install.js fails because it cannot find proper proxy (no settings in npm, no HTTPS_PROXY env variable)
  2. node-gyp rebuild fails because node and node-gyp are not installed

Solution

  1. Export env variable before running maven
export HTTP_PROXY=http://proxy:port HTTPS_PROXY=http://proxy:port
  1. Install node, node-gyp and build-essential linux packages before running maven

We went with an option 1.