Caddy
This example uses Caddy, one of the most popular web servers.
Caddy can be used with Unikraft / Unikraft Cloud to serve static web content.
To run this example, follow these steps:
-
Install the
kraftCLI tool and a container runtime engine, for example Docker. -
Clone the
examplesrepository andcdinto theexamples/caddy/directory:
Code(bash)
Make sure to log into Unikraft Cloud by setting your token and a metro close to you.
This guide uses fra (Frankfurt, ๐ฉ๐ช):
Code(bash)
When done, invoke the following command to deploy this app on Unikraft Cloud:
Code(bash)
The output shows the instance address and other details:
Code(ansi)
In this case, the instance name is caddy-vhf4m and the address is https://frosty-sky-vz8kwsmb.fra.unikraft.app.
They're different for each run.
Use curl to query the Unikraft Cloud instance of Caddy.
Code(bash)
Code(text)
You can list information about the instance by running:
Code(bash)
Code(text)
When done, you can remove the instance:
Code(bash)
Customize your app
To customize the app, update the files in the repository, listed below:
Kraftfile: the Unikraft Cloud specificationrootfs/var/www/index.html: the index page of the content servedrootfs/etc/caddy/Caddyfile: the Caddy configuration file
Update the contents of the rootfs/var/www directory to serve different static web content.
For example, you could change the contents of rootfs/var/www/index.html to:
Code(html)
After re-deploying the Caddy image on Unikraft Cloud, using curl or a browser to query it will present the new page contents.
You can generate the static web content in rootfs/var/www/ offline with tools such as Jekyll or Hugo.
If required, you can also customize the configuration of Caddy in rootfs/etc/caddy/Caddyfile.
You can set a new webroot (different than rootfs), or a different internal port, or a different index page, etc.
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Code(bash)
Or visit the CLI Reference.