This repository is an example of an application with backend and frontend both in Scala that can be deployed easily on fly.io.
It features:
- frontend with Laminar
- frontend web-component library with UI5
- frontend packaging with vitejs
- backend (on the JVM) with cask
- fat jar generation with sbt-assembly
- backend hot reload with sbt-revolver
- JSON serialization with circe
To run this project, you will need installed
- node.js (v16+)
- sbt
- a jdk 11
The first time, run in one terminal:
cd frontend
npm ci
Then, in one terminal:
sbt
~frontend/fastLinkJS
In another terminal
sbt
~server/reStart
In a third (last) terminal
cd frontend
npm run dev
Then you can go to localhost:3000/static
.
You can package the whole application into a fat jar with
sbt packageApplication
Then you can run it with java -jar dist/app.jar
then go to localhost:9000
.
You can also build a Docker image for the app with (note that the tag name does not matter)
docker build --tag demoscalaflyio .
Then run it with
docker run --rm -p 9000:8080 demoscalaflyio
and then go to localhost:9000
.
The project contains a fly.toml
file generated via fly launch
.
You can apply it to your account via fly deploy
and then see that it's live with fly open
. (If not logged in already, you need to fly auth login
.)
You need to have flyctl installed for this to work.
You can see more complete instructions here.