Elixir
In this guide we create and deploy a simple Elixir-based HTTP web server. To run this example, follow these steps:
-
Install the
kraft
CLI tool and a container runtime engine, e.g. Docker. -
Clone the
examples
repository andcd
into theexamples/http-elixir1.16/
directory:
Code
Make sure to log into Unikraft Cloud by setting your token and a metro close to you.
We use fra0
(Frankfurt, ๐ฉ๐ช) in this guide:
Code
When done, invoke the following command to deploy this application on Unikraft Cloud:
Code
The output shows the instance URL and other details:
Code
In this case, the instance name is elixir-qo9k3
and the URL is https://small-water-tl8lr8am.dal0.kraft.host
.
They are different for each run.
Use curl
to query the Unikraft Cloud instance of the Elixir-based HTTP web server:
Code
Code
At any point in time, you can list information about the instance:
Code
Code
When done, you can remove the instance:
Code
Customize your Application
To customize the application, update the files in the repository, listed below:
lib/
,mix.esx
: the actual Elixir HTTP serverKraftfile
: the Unikraft Cloud specificationDockerfile
: the Docker-specified application filesystem
The following options are available for customizing the application:
-
If only updating the implementation in the
lib/server.ex
orlib/server/application.ex
source code files, no other changes are required. If new source files are added in thelib/
directory, no other change is required. -
If new files are added, these have to be copied in the application filesystem, using the
COPY
command in theDockerfile
. -
More extensive changes may require expanding the
Dockerfile
with additionalDockerfile
commands.
The current source code files and configuration file (mix.exs
) are generated using:
Code
Use a similar command to create a new application. Then update it and deploy it on Unikraft Cloud using the above instructions.
Learn More
Use the --help
option for detailed information on using Unikraft Cloud:
Code
Or visit the CLI Reference.