A minimal example of a lightweight webapp in OCaml.
It features a possible organization of files to maximize code sharing between server (native OCaml) and client (BuckleScript). Some of the things shared are:
Potentially, shared folder can contain other shared code like validation functions, data processing, etc.
Create an opam local switch:
make create-switchInstall dune in the newly created switch:
opam install duneInstall all dependencies:
make depsBuild client:
yarn webpack:dev
Build and run the server:
make runOpen the browser and go to http://localhost:3000/.
It's also possible to get hot reloading while developing. For that, start the server (to be able to serve API requests) with make run, run BuckleScript in yarn start and then start Webpack dev server with yarn server.
docker-compose -f docker-compose.dev.yml up -d
Right now, the example allows to easily deploy the app to Heroku. Build times are longer than they should, but hopefully this will be fixed soon.
heroku create your_app from the app foldercontainer: heroku stack:set containergit push heroku master