Quick Start
Clone our sample Hello World project:
git clone git@github.com:benchkram/bob-quick-start.git
cd bob-quick-start
Inside bob-quick-start
, you'll notice a bob.yaml
file.
This file, also called Bobfile, contains the instructions for all the build tasks of your project:
build:
build:
input: |-
main.go
go.mod
go.sum
cmd: go build -o ./build/server main.go
target: /build/server
dependencies:
- go_1_18
Running bob build
will build the whole project from scratch:
bob build
Building nix dependencies...
Succeeded building nix dependencies
Running task build with 0 dependencies
build running task...
build ...done
โ โ โ โ
Ran 1 tasks in 330ms
build โ (330ms)
You might have noticed that you didn't have to install Go for this application to work. bob takes care of installing all your project dependencies by using Nix under the hood which provides packages for all major programming languages and tools.
This enables you to compose build environments very easily without relying on docker images. Instead of sending sources (build context) to the docker deamon the environment is mounted to your sources, which can be a huge performance improvement.
The binary for our server has been built inside ./build
directory. You can now run it:
./build/server
If you go to http://localhost:3333/ you should see Hello World!
.
Run bob build
again, now it's much faster because bob will cache the build outputs. If the first build
took 330ms
now the second build only took 1ms
.
$ bob build
Building nix dependencies...
Succeeded building nix dependencies
Running task build with 0 dependencies
โ โ โ โ
Ran 1 tasks in 1 ms
build cached
Let's change the main.go
file from "Hello, World!"
to "Hello, Bob!"
:
func Hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, Bob!")
}
Now when we run bob build
again, we see the project is built again because main.go
has changed:
Building nix dependencies...
Succeeded building nix dependencies
Running task build with 0 dependencies
build running task...
build ...done
โ โ โ โ
Ran 1 tasks in 341 ms
build โ (340ms)
bob figured out that the source code has changed and rebuilt the binary.
This is all you need to know to get started. However, we only scratched the surface of what bob can do. To learn more head over to the next section!