# Vite (vanilla)

import { Tabs, TabsContent, TabsList, TabsTrigger } from "zudoku/ui/Tabs"

{/* vale off */}
{/* THIS FILE WAS AUTOGENERATED FROM THE PUBLIC EXAMPLE REPOSITORY. DO NOT EDIT THIS FILE DIRECTLY. */}


This example demonstrates how to run a [Vite](https://vite.dev) project which
executes via the `vite` program on top of the `node` runtime.

:::note
This is **not** the most efficient way to run a Vite project! See
[`httpserver-nginx-vite-vanilla`](../httpserver-nginx-vite-vanilla/) for more details.
:::


## Initialization

The project was instantiated via:

```
npm create vite@latest my-vue-app -- --template vanilla
```

The accompanying `Dockerfile` and `Kraftfile` are
necessary for deploying to Unikraft Cloud.


## Deployment

To run this example, follow these steps:

1. Install the [unikraft CLI](/cli).
   You need a [BuildKit](https://github.com/moby/buildkit) builder. The easiest way to get one is via [Docker](https://docs.docker.com/engine/install/).
   Alternatively, you can also directly set up and use BuildKit, see the [quick start](https://github.com/moby/buildkit#quick-start).

2. Clone the [`examples` repository](https://github.com/unikraft-cloud/examples) and `cd` into the `examples/httpserver-node-vite-vanilla/` directory:

   ```bash
   git clone https://github.com/unikraft-cloud/examples
   cd examples/httpserver-node-vite-vanilla/
   ```

Make sure to log into Unikraft Cloud and pick a [metro](/platform/metros) close to you.
This guide uses `fra` (Frankfurt, 🇩🇪):

```bash
unikraft login
```

When done, run:

```bash
unikraft build . --output <my-org>/httpserver-node-vite-vanilla:latest
unikraft run --metro fra \
  -m 4G \
  -p 443:8080/tls+http \
  --scale-to-zero policy=on,cooldown-time=2000,stateful=true \
  -e PWD=/app \
  --image <my-org>/httpserver-node-vite-vanilla:latest
```

The output shows the instance address and other details:

```ansi
[1mmetro[22m:        fra
[1mname[22m:         httpserver-node-vite-vanilla-w9f3p
[1muuid[22m:         4d5e6f7a-8b9c-0d1e-2f3a-d4e5f6a7b8c9
[1mstate[22m:        [38;2;144;161;185mstarting[0m
[1mimage[22m:        <my-org>/httpserver-node-vite-vanilla
[1mresources[22m:
[3m  memory[23m:     4096MiB
[3m  vcpus[23m:      1
[1mservice[22m:
[3m  uuid[23m:       5e6f7a8b-9c0d-1e2f-3a4b-e5f6a7b8c9d0
[3m  name[23m:       bold-rain-mv5tx8wy
[3m  domains[23m:
[3m  - fqdn[23m:     bold-rain-mv5tx8wy.fra.unikraft.app
[1mnetworks[22m:
[3m- uuid[23m:       6f7a8b9c-0d1e-2f3a-4b5c-f6a7b8c9d0e1
[3m  private-ip[23m: 10.0.5.2
[3m  mac[23m:        12:b0:6c:3e:ab:95
[1mtimestamps[22m:
[3m  created[23m:    just now
```

In this case, the instance name is `httpserver-node-vite-vanilla-w9f3p` and the address is `https://bold-rain-mv5tx8wy.fra.unikraft.app`.
They're different for each run.

After deploying, you can query the service using the provided URL.


You can list information about the instance by running:

```bash
unikraft instances list
```

```ansi
[1mMETRO[22m  [1mNAME[22m                                [1mSTATE[22m    [1mIMAGE[22m                                  [1mARGS[22m  [1mMEMORY[22m   [1mVCPUS[22m  [1mFQDN[22m                                 [1mCREATED[22m
fra    httpserver-node-vite-vanilla-w9f3p  [38;2;0;188;125mrunning[0m  <my-org>/httpserver-node-vite-vanilla        4096MiB  1      bold-rain-mv5tx8wy.fra.unikraft.app  2 minutes ago
```

When done, you can remove the instance:

```bash
unikraft instances delete <instance-name>
```

## Learn more

- [NGINX's Documentation](https://nginx.org/en/docs)
- [Vite's Documentation](https://vite.dev/guide/)
- [Unikraft Cloud's Documentation](https://unikraft.cloud/docs)
- [Building `Dockerfile` images with `Buildkit`](https://unikraft.org/guides/building-dockerfile-images-with-buildkit)
- [Vite (vanilla) static build on Unikraft Cloud](../httpserver-nginx-vite-vanilla)
- [Vite (vanilla) SSR mode on Unikraft Cloud](../httpserver-node-vite-ssr-vanilla)


Use the `--help` option for detailed information on using Unikraft Cloud:

```bash
unikraft --help
```

Or visit the [CLI Reference](/cli/unikraft).
{/* vale on */}
