- create an account on heroku.com
- having one free dyno not already created (two dyno is the maximum for a free heroku account currently)
- install heroku CLI
- install sdkman/grails3
Create a new grails default app and create a file named "Profile":
$ grails create-app myapp
$ cd myapp
$ touch Procfile
"Procfile" is important for heroku plateform to configure the way the app will be launched on the plateform, copy paste this in Procfile:
web: cd build ; java -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war
Then open the project inside your favorite IDE and edit build.gradle by adding this at the end of the existing file:
task stage() {
dependsOn clean, war
}
tasks.stage.doLast() {
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/assetCompile")
delete fileTree(dir: "build/distributions")
delete fileTree(dir: "build/libs", exclude: "*.war")
}
war.mustRunAfter clean
task copyToLib(type: Copy) {
into "$buildDir/server"
from(configurations.compile) {
include "webapp-runner*"
}
}
stage.dependsOn(copyToLib)
and also add dependencycompile 'com.github.jsimone:webapp-runner:8.5.11.3'
in the dependency section.This dependency is for heroku to launch the app/
Then the git part:
$ git init
Initialized empty Git repository in .git/
$ git add .
$ git commit -m "first comit"
Created initial commit 5df2d09: first commit
44 files changed, 8393 insertions(+), 0 deletions(-)
create mode 100644 README
create mode 100644 Procfile
create mode 100644 app/controllers/source_file
...
Then create the heroku remote repository:
$ heroku create
$ git remote -v
heroku https://git.heroku.com/thawing-inlet-61413.git (fetch)
heroku https://git.heroku.com/thawing-inlet-61413.git (push)
$ git push heroku master
Initializing repository, done. updating 'refs/heads/master'
check the result by using
$ heroku open
Sources:
https://devcenter.heroku.com/articles/git#prerequisites-install-git-and-the-heroku-cli
https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku
Aucun commentaire:
Enregistrer un commentaire