Build a Project
Up to this point, the walking skeleton has been running in development mode. Once you’ve added meaningful features, you can deploy your application to production. To do that, you have to make a production build. The build gathers necessary frontend resources and dependencies. It then transpiles, minimizes and bundles them to make the application load faster.
Make a Production Build
In the walking skeleton, you use the Vaadin Maven plugin to make a production build. You do this by activating the production
profile, like this:
Source code
bash
./mvnw clean package -Pproduction
bash
powershell
powershell
Once the build has finished, check the target
directory. If your skeleton was named my-application
, you should find a file called my-application-1.0-SNAPSHOT.jar
.
The production
profile not only builds the frontend, but also excludes the development server bundle since it contains features that aren’t used in production.
Build a Docker Image
The walking skeleton includes a Dockerfile
that allows you to package your application as a Docker image.
Important
|
Install Docker
You must install Docker on your system before you can build an image.
|
Run the following command from your project root to build the image:
Source code
terminal
docker build -t my-application:latest .
This command builds your application in production mode and produces a Docker image tagged my-application:latest
.
Building with Commercial Components
If your application uses commercial components, you need a licence key.
When building locally with Maven, the Vaadin Maven plugin detects the license automatically. For Docker builds, you must pass the key explicitly as a secret:
Source code
bash
docker build -t my-application:latest --secret id=proKey,src=$HOME/.vaadin/proKey .
bash
powershell
powershell
If you need to use an offline key, you can pass it like this:
Source code
bash
docker build -t my-application:latest --secret id=offlineKey,src=$HOME/.vaadin/offlineKey .
bash
powershell
powershell
Note
|
A Peek Under the Hood
The Source codedocker
For more information about build secrets in Docker, see the Docker documentation. |