One of the easiest ways to deploy Grails 3.x is to build an executable jar file that embeds a servlet container (Tomcat, Undertow, etc) with the application.
Modify build.gradle
:
// Remove or comment out the war plugin:
// apply plugin:"war"
// Enable the executable jar:
springBoot {
executable = true
}
// Optional: Customize the jar properties:
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html
jar {
archiveName('myapp.jar')
}
Build using ./gradlew assemble
Resulting jar is now a fully executable app you can startup:
$ head build/libs/myapp.jar
#!/bin/bash
#
# . ____ _ __ _ _
# /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
# ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
# \\/ ___)| |_)| | | | | || (_| | ) ) ) )
# ' |____| .__|_| |_|_| |_\__, | / / / /
# =========|_|==============|___/=/_/_/_/
# :: Spring Boot Startup Script ::
#
You can start it as you would normally for any command line app:
$ ./build/libs/myapp.jar Grails application running at http://localhost:8080 in environment: production
It also behaves like an init service:
$ ln -s /opt/myapp/myapp.jar /etc/init.d/myapp
$ service myapp [start|stop|status|restart]
Detailed documentation is under the spring-boot docs: http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html