Phoenix is a web development framework written in Elixir, designed for building scalable and maintainable applications. This example demonstrates how to deploy a Phoenix application with a PostgreSQL database on Unikraft Cloud.
This example app has been generated using Phoenix Express, and the Dockerfile
used for building the rootfs was generated following the instructions here.
To run this example, follow these steps:
Install the unikraft CLI.
You need a BuildKit builder. The easiest way to get one is via Docker.
Alternatively, you can also directly set up and use BuildKit, see the quick start.
Clone the examples repository and cd into the examples/phoenix-postgres directory:
Replace <your-secret-key-base> in the commands below with the generated value, and update the password in DATABASE_URL to match the one set for PostgreSQL.
Then, deploy the Phoenix instance:
In this case, the instance names are postgres-ik5at and phoenix-hd29m.
They're different for each run.
Use a browser to access the Phoenix application using the URL from the fqdn field in the output.
You can list information about the instances by running:
Code
unikraft instances list
Code
METRO NAME STATE IMAGE MEMORY VCPUS FQDN CREATEDfra phoenix-hd29m running <my-org>/phoenix 2GiB 1 wild-moon-pkwsqc49.fra.unikraft.app just nowfra postgres-ik5at standby <my-org>/postgres 2GiB 1 postgres.internal 3 minutes ago
This deployment creates a volume (db-data) for PostgreSQL data persistence.
The volume persists after removing instances, allowing you to redeploy without losing data.
To remove the volume: