Gradle CI/CD issue

Hi! Having some issues with the gradle example gitlab-ci.yml here:

I’ve written the code for a websocket client and made sure it works. But the above example doesn’t state how I should be deploying gradle projects. So this is what I’ve added to the end of the Gradle.gitlab-ci.yml example to get it to work with my project:

deploy:
script:
- gradle run
cache:
key: “$CI_COMMIT_REF_NAME”
policy: pull
paths:
- build
- .gradle

and put the following in the build.gradle:

plugins {
id ‘java’
id ‘application’
}

application {
mainClassName = ‘Collector’
}

so that the “gradle run” command works. But the thing is that “gradle run” blocks my gitlab-runner (the docker executor). Course, if I do “gradle run &” it exits the shell after. But since the process is attached to that shell, the application dies as well. The gradle image doesn’t have tmux either, it seems.

Obviously, I don’t understand this so in addition to a reply I would love to know any good sources to learn gitlab-ci. But my question right now is how I should make sure the docker image keeps running after the runner exits the shell.

What I want is a docker image to be started on my server and run my application for a long time, without having the runner connected to it.

Thank you in advance for any answer!