https://github.com/erikh/exercise-website
A website to track my exercise regimen; full stack in a single binary. Made in rust+react.
https://github.com/erikh/exercise-website
Last synced: about 1 year ago
JSON representation
A website to track my exercise regimen; full stack in a single binary. Made in rust+react.
- Host: GitHub
- URL: https://github.com/erikh/exercise-website
- Owner: erikh
- License: mit
- Created: 2023-03-29T11:47:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-07T12:55:16.000Z (over 2 years ago)
- Last Synced: 2025-02-08T10:42:39.937Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 487 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Exercise Website
I needed an app to track my daily exercise and keep me honest.
This uses [davisjr](https://github.com/erikh/davisjr) to serve a
binary-embedded react application which posts to a database. It could serve as
an example application for that toolkit.
The resulting binary is approximately 7MB with the current release build
settings and only links against libc. It requires no other infrastructure to
function as a web application.
### Development
First off, make sure your node environment is in order. `cd react_app && npm i`
is probably a good first step, and if things still break a `npm i --global
react-scripts` will probably get you the last mile.
Type `make`. A `cargo install --path .` will bundle the whole website into the
binary, so it can be served by e.g. a container with ease, but it does not
compile the react payload without typing `make`. Eventually I will write a
proper `build.rs` for it. The resulting binary does not need `nginx` or any
other supporting infrastructure unless you want to manipulate the transport
somehow. It just listens on port 3000.
The application provides no authentication or authorization control.
The handlers this program implements mimic the `try_files` directive of `nginx`
so that it is compatible with `react-router`'s behavior. What this means is
that in all cases where a filename does not match, it is forwarded to
`/index.html` with the target path appended to it. This way, `react-router` can
route the path with javascript.
### Deployment
`make docker` will build the react application and then build a local docker
image called `exercise-website`. It uses the rust image as a build stage and
then copies the assets into a thinner image.
### Author
Erik Hollensbe
### License
MIT