Escriu per cercar…

Deploy

Aquesta pàgina encara no s'ha traduït — es mostra en l'idioma original:English

Introduction

Deployment

Suppose you have a Ktor application named app and you want to deploy it to a remote server.

Fat JAR

Deploying a Ktor application involves packaging your code into a runnable format (usually a “Fat JAR”) and configuring a remote server to run it continuously while handling incoming web traffic.

Executable JAR file

To run the application on a server, you need to bundle your code and all its dependencies into a single, executable JAR file.

Open your terminal in the root of your project and run the build command:

shell
./gradlew buildFatJar

Once the build succeeds, locate your packaged application. It will be located at build/libs/ and will likely be named something like app.jar.

Server

Connect to your server via SSH and install the Java Runtime Environment (JRE) so it can execute your JAR file.

shell
ssh username@your_server_ip

Update your package manager and install Java (replace 17 with 21 if your project uses Java 21):

shell
sudo apt update
sudo apt install openjdk-17-jre-headless -y

Create a directory to hold your application:

shell
sudo mkdir /opt/app
sudo chown $USER:$USER /opt/app

Estàs llegint una vista prèvia.

Inicia sessió per llegir l'article complet. Qualsevol compte obre 4 articles gratuïts al mes; l'alumnat i el professorat llegeixen les pàgines del seu curs sense límit.

Inicia sessió