-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vite setup and deployment and logging changes (#4)
- Loading branch information
Showing
18 changed files
with
3,749 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,63 @@ | ||
## Web app to generate Scala 3 Native bindings for C | ||
|
||
_Warning: this is currently not working and really should be a private repo, but I've run out of private GHA minutes so... here we are_ | ||
|
||
<!--toc:start--> | ||
- [Web app to generate Scala 3 Native bindings for C](#web-app-to-generate-scala-3-native-bindings-for-c) | ||
- [Quick start](#quick-start) | ||
- [Local development](#local-development) | ||
- [Quick start (Docker)](#quick-start-docker) | ||
- [Local development (backend)](#local-development-backend) | ||
- [Local development (frontend)](#local-development-frontend) | ||
<!--toc:end--> | ||
|
||
_Warning: unfortunately the app doesn't seem to currently work on Linux x86, which is where I want to deploy it on Fly.io. I've only made the repository public to invite some folks to take a look and see what am I missing. The app is very much work in progress, and so is the accompanying blog post._ | ||
![2023-05-29 12 01 15](https://github.com/indoorvivants/sn-bindgen-web/assets/1052965/85d0144c-f431-49e3-a45c-b644fc642cf7) | ||
|
||
_For context, what doesn't work is the service started at port 9999 - you can verify that by hitting /api/health in the built container. On the other hand, the other service starts fine - you can verify that by hitting /health endpoint on the service responding at :8888_ | ||
### Quick start (Docker) | ||
|
||
![2023-05-29 12 01 15](https://github.com/indoorvivants/sn-bindgen-web/assets/1052965/85d0144c-f431-49e3-a45c-b644fc642cf7) | ||
**Warning: this will take some time, as we need to build NGINX Unit from scratch, and install LLVM. Sit back, have a beverage** | ||
|
||
### Quick start | ||
- Build a docker container | ||
|
||
1. Install [Earthly](https://docs.earthly.dev) | ||
Release version (slow): | ||
|
||
2. Build a Docker Container | ||
``` | ||
earthly +docker | ||
$ docker build . --build-arg scalanative_mode=debug --build-arg scalanative_lto=none -t sn-bindgen-web | ||
``` | ||
**Warning: this will take some time, as we need to build NGINX Unit from scratch, and install LLVM. Sit back, have a beverage** | ||
3. Run it | ||
Debug version (slightly faster): | ||
``` | ||
docker run -p 9999:9999 bindgen-web:latest | ||
$ docker build . --build-arg scalanative_mode=debug --build-arg scalanative_lto=none -t sn-bindgen-web | ||
``` | ||
4. Open `http://localhost:9999` and enjoy. | ||
- Run it | ||
### Local development | ||
``` | ||
docker run -p 9999:9999 sn-bindgen-web:latest | ||
``` | ||
- Open `http://localhost:9999` and enjoy. | ||
### Local development (backend) | ||
1. Install NGINX Unit: https://unit.nginx.org/installation/ | ||
2. Install LLVM: https://releases.llvm.org/ | ||
3. Set `LLVM_BIN` env variable to the location of `bin` folder in LLVM installation | ||
4. Run `sbt deployLocally` | ||
4. Run `sbt devServer/run` | ||
**Warning: first run will be very slow. Subsequent ones will be somewhat slow.** | ||
Alternatively, you can keep launch SBT and run `devServer/reStart` in there - this | ||
will make sure that your SBT shell remains usable, and the server will be run in the background. | ||
5. Open `http://localhost:9999` and enjoy. | ||
### Local development (frontend) | ||
The frontend module is set up using [Vite.js](https://vitejs.dev/). | ||
- `cd modules/frontend` | ||
- `npm install` | ||
- Run the backend (see above), it has to be running on port 9999 (default) | ||
as Vite is configured to proxy the `/api/*` requests to `http://localhost:9999/api/*` | ||
- In a separate SBT shell, run `~frontend/fastLinkJS` - this continuously rebuilds the Scala.js frontend | ||
- `npm run dev` - will run the Vite server | ||
- Open http://localhost:5173 and you can now edit frontend without restarting the backend, with live reload | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'scalajs:main.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link rel="stylesheet" | ||
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/night-owl.min.css"> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/scala.min.js"></script> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.45.0/codemirror.min.css"> | ||
<link rel="stylesheet" href="/styles.css"> | ||
<title>Scala 3 Native bindings generator</title> | ||
</head> | ||
<body class = "bg-blue-950"> | ||
<div id="appContainer"></div> | ||
<script src="/frontend.js" type="module"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.45.0/codemirror.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.45.0/mode/clike/clike.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.