A local multi-application development server.
There’s support for running multiple services for handling things like CSS
preprocessors and background jobs (similar to Foreman). There’s also
built-in support for managing dependencies using asdf, loading
environment variables with direnv, and running per-app instances of
PostgreSQL.
brew install caddyCreate a resolver file so .test domains resolve to localhost:
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/test'Caddy automatically generates SSL certificates for local domains. Trust its root CA so browsers accept the certificates:
caddy trustBates ships two binaries: batesd (the server, a Mix release) and
bates (a thin escript client for control commands). From source/:
mix deps.get
mix escript.build # produces source/bates (the CLI)
MIX_ENV=prod mix release batesd # produces source/_build/prod/rel/batesd/Run the daemon in the foreground:
_build/prod/rel/batesd/bin/batesdPass --config <path> to override the default config location
(~/.config/bates/config.toml). Ctrl-C shuts the daemon down.
The bates escript talks to the running daemon via the JSON API.
With bates and batesd both on $PATH:
bates status
bates env myappThe configuration file is defined in TOML format.
[test_server]
root = "/apps/test_server"
command = "rails server -p $PORT"
addons = ["postgresql"]
middleware = ["direnv"]The command will have the $PORT placeholder replaced with a dynamically
assigned port at startup. A port may be manually specified via the port key,
instead.
Multiple services are supported, as well.
[multi_service_app]
root = "/apps/multi_service_app"
middleware = ["direnv"]
[multi_service_app.services.web]
hostname = true
command = "bin/rails server"
[multi_service_app.services.css]
command = "bin/rails tailwindcss:watch[always]"