Templatus is an opinionated template to build web applications with Ruby on Rails and Inertia (using Svelte.js). It simplifies the process of setting up a new application while following best practices.
.test
TLD (instead of localhost:3000
) and https
in developmentThis template is developed with optimized performance and security in mind. The following benchmarks are performed against the demo installation on production. It uses an inexpensive virtual server on the Hetzner Cloud behind a Traefik setup.
100% in all categories.
What's the red Permissions-Policy badge? This seems to be fixed with one of the next Rails update: https://github.com/rails/rails/pull/41994
176 KB of compiled JavaScript (after tree-shaking, minified & uncompressed).
$ RAILS_ENV=production bin/rails assets:precompile
yarn install v1.22.19
[1/6] š Validating package.json...
[2/6] š Resolving packages...
success Already up-to-date.
āØ Done in 0.11s.
Building with Vite ā”ļø
vite v4.4.11 building for production...
transforming...
ā 4980 modules transformed.
rendering chunks...
computing gzip size...
../../public/vite/manifest-assets.json 0.10 kB ā gzip: 0.09 kB
../../public/vite/assets/logo-10f03a2b.svg 0.50 kB ā gzip: 0.30 kB
../../public/vite/manifest.json 0.57 kB ā gzip: 0.22 kB
../../public/vite/assets/application-e151bf91.css 21.46 kB ā gzip: 4.88 kB
../../public/vite/assets/application-eb9572d8.js 29.73 kB ā gzip: 11.17 kB ā map: 58.05 kB
../../public/vite/assets/vendor-597444d4.js 181.57 kB ā gzip: 61.41 kB ā map: 818.86 kB
ā built in 21.26s
Build with Vite complete: /Users/ledermann/Projects/templatus-inertia/public/vite
Small footprint: The demo application transfers only 71 KB of data on the first visit.
With multi-stage building and using DockerRailsBase the build of the Docker image takes very little time. Currently, the deploy
job requires about 1,5 minutes on GitHub Actions (see https://github.com/templatus/templatus-inertia/actions)
The Docker image is based on Alpine Linux and is optimized for minimal size (currently 115 MB uncompressed disk size). It includes just the bare minimum - no build tools like Node.js, no JS sources (just the compiled assets), no tests.
$ container-diff analyze ghcr.io/templatus/templatus-inertia -n
-----Size-----
Analysis for ghcr.io/templatus/templatus-inertia:
IMAGE DIGEST SIZE
ghcr.io/templatus/templatus-inertia sha256:... 115M
git clone [email protected]:templatus/templatus-inertia.git
cd templatus-inertia
Brewfile
:brew bundle
sudo puma-dev -setup
puma-dev -install
puma-dev link
# Use Vite via puma-dev proxy
# Adopted from https://github.com/puma/puma-dev#webpack-dev-server
echo 3036 > ~/.puma-dev/vite.templatus-inertia
bin/setup
bin/dev
Replace all instances of rails-svelte-inertia-tinker with the directory that this project appears in Then open https://rails-svelte-inertia-tinker.test in your browser.
RuboCop:
bin/rubocop
ESLint:
bin/yarn lint
TypeScript compiler:
bin/yarn tsc
Ruby tests:
bin/rspec
open coverage/index.html
JavaScript unit tests:
bin/yarn test
E2E tests with Cypress:
bin/cypress open
This opens Cypress and starts Rails in development
environment, but with CYPRESS=true
, so the test
database is used. This allows code editing without class reloading and recompiling assets.
To run Cypress in headless mode:
bin/cypress run
docker network create public
docker-compose up