Run it
Keep a service running from the same definition that built it.
A build produces files. A runnable keeps something running, backed by a build, so the thing serving your site is the thing bldr just built.
Declare a service
import { runnable } from "bldr";
import nginxImage from "nginx";
scope.addRunnable(
"web",
runnable().service("web", {
image: nginxImage,
mounts: [{ source: site, dest: "/usr/share/nginx/html" }],
ports: [{ host: 8080, pod: 80 }],
}),
);site is the same Directory the output target uses. One definition, two
uses: exported as files, and mounted into a running container.
Add nginx to your workspace members the same way you added node.
Start it
bldr run site:web --name "serve the site"bldr run <member>:<runnable> builds what the runnable needs, starts it, and
streams its logs. Visit http://localhost:8080.
Manage it
bldr runs # what is running
bldr runs stop <RUN-ID> # stop oneKeep it following the build
bldr build --run site/web --watch --name "live site"--run attaches the runnable to the build as a post-build action, and
--watch rebuilds when the workspace changes. Now editing your source
re-points the running service at the new build. A mount the runnable marks
hot-swappable is swapped underneath without a restart; anything else restarts
that pod and whatever depends on it.
Stopping the build leaves the run up on the last thing it was given. Stopping a build does not tear down what it started.
Next: deploy it.