Creating new application in Coolify - CodeHavenX/MonoRepo GitHub Wiki
This guide expects that all the steps in the steps in the Server Infrastructure guide has been followed.
Additionally, we are assuming that the applications being deployed are following our regular stack of:
- Kotlin
- Gradle
- Compose
- Cloudflared
- Open the Coolify Dashboard and go to the project you want to use(you can also create a new project if needed).
- Select the environment you want to use or create a new one if needed.
- Select the Private Repository(with Github App) option. This option will allow Coolify to automatically deploy new commits.
- If you have not added a Github app yet, you will have to do that right now. Follow the steps in the UI to add Coolify as an integration with Github. In the step to set the
Webhook Endpoint
ensure to change the URL to match the one you need. Otherwise the callback will not work. Also ensure that you have the host configured with https and set to be accesible through a domain name.
- If you have not added a Github app yet, you will have to do that right now. Follow the steps in the UI to add Coolify as an integration with Github. In the step to set the
- Select the server where you will deploy this application.
- Select the Github App that you created previously.
- Select the Github repository and load it.
- Select the appropriate branch, the Build Pack should be Nixpacks. The port can be the default one. Ensure that **Is it a static site? ** is unchecked.
- Now in the Configuration, General screen, remove all the values in the Domains.
- In the Build Command field, set the command needed to build a jar with all dependencies(a fat jar). This will generally be just
./gradlew <PROJECT>:buildFatJar
. This command will be run from the root of the repo, so you can use relative paths. - In the Start Command set the command to run the
*.jar
file previously created. This will generally be justjava -jar <PROJECT_PATH>/build/libs/<MODULE_NAME>-all.jar
. This command will be run from the root of the repo, so you can use relative paths. - In the Ports Exposes, set the port in which the server is listening. This will depend on the project. For ktor projects this is generally 8080.
- In the Port Mapping, set the mapping between the internal port(docker) to the external port(host). For example if you want to expose the internal port
8080
to the external port9090
, the field would be9090:8080
. - Click Save and then Deploy.
- You should ensure that the service has a valid healthcheck endpoint, otherwise you should disable healthcheck.
- Now you should be able to make a call to the URL you defined previously and get a response 😃.
- Select the appropriate branch, the Build Pack should be Nixpacks. The port can be the default one. Ensure that Is it a static site? is checked.
- Now in the Configuration, General screen, remove all the values in the Domains.
- In the Build Command field, set the command needed to build the wasm client. This will generally be just
./gradlew <PROJECT>:wasmJsBrowserDistribution
. - Set the Publish Directory to the folder in which the application will be created. For compose apps, this folder is generally
/<PROJECT_FOLDER_PATH>/build/dist/wasmJs/productionExecutable
. Remember to use a relative path to the root of the repo and also having the path start with a/
. - In the Port Mapping, set the mapping between the internal port(docker) to the external port(host). For example if you want to expose the internal port
11000
to the external port80
, the field would be11000:80
. For this case we will use 80 as the internal port since the container will be running nginx. The external port can be anything you want, as long as it is an available port. - Click Save and then Deploy.
- You should ensure that the service has a valid healthcheck endpoint, otherwise you should disable healthcheck.
Now that your application is running and accesible locally, it is time to make it accesible to the internet. This step is the same regardless if your created a client or server application. All you will need is the host port to which your application is bound.
To do this, follow the steps here: https://coolify.io/docs/knowledge-base/cloudflare/tunnels#one-domain-one-resource