Escribe para buscar…

Deploy

Esta página todavía no se ha traducido — se muestra en su 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 leyendo una vista previa.

Inicia sesión para leer el artículo completo. Cualquier cuenta abre 4 artículos gratuitos al mes; el alumnado y el profesorado leen las páginas de su curso sin límite.

Iniciar sesión