Monorepos (mono repositories) are repositories that contain multiple applications. Often enough, a server app, but maybe also a command line tool or a background worker.
There are various approaches to this, one of them, is individual apps in a cmd/
structure.
To instruct Runway’s builder to build multiple applications (from the cmd/
folder):
runway app config set BP_GO_TARGETS=./cmd/server:./cmd/cli
[build]
[[build.env]]
name = "BP_GO_TARGETS"
value = "./cmd/server:./cmd/cli"
The order of the applications in BP_GO_TARGETS
matters: the first one will be the web process, while the second one will be included in your container, but will not be routable.
Consider the following structure in your repository:
cmd/server/main.go
cmd/cli/main.go
cmd/worker/main.go
Adding all three of them to BP_GO_TARGETS
, will produce the following programs (or binaries) inside the application container:
server
cli
worker
runway app exec
, for example, to invoke the CLI, you can run runway app exec cli
from your computer! The tools will be in the same container and will have access to the full environment!Procfile
, read on.