Create Production Builds

2024-03-28

By default, running gradlew deployApp creates a development build. It creates the minimum number of build artifacts required to run LabKey Server on a development machine. Some of these artifacts aren't required to run LabKey Server (such as pre-creating a .gz version of resources like .js files so the web server doesn't need to dynamically compress files for faster download), and others can be used directly from the source directories when the server is run in development mode (via the -DdevMode=true JVM argument). This means the development builds are faster and smaller than they would otherwise be.

Note that individual modules built in development mode will not deploy to a production server. On deployment, the server will show the error: "Module <module-name> was not compiled in production mode". You can correct this by running

gradlew deployApp -PdeployMode=prod --no-build-cache

or, to build an individual module in production mode, you can add the following line to the module.properties file.

BuildType: Production

Production servers do not have access to the source directories, and should be optimized by performance, so they require that all resources be packaged in each module's build artifacts. This can be created by running gradlew deployApp -PdeployMode=prod --no-build-cache instead. If you have existing build artifacts on your system, you will need to do an gradlew cleanBuild first so that the build recognizes that it can't use existing .module files. The --no-build-cache switch ensures that gradle doesn't pull pre-built dev mode artifacts from its cache.

All standard LabKey Server distributions (the .zip and .tar.gz downloads) are compiled in production mode.

Related Topics