Learn to use Vib through these simple recipe examples.
Showcasing a simple Node.js application containerized with Vib.
name: my-recipe
id: my-node-app
stages:
- id: build
base: node:current-slim
labels:
maintainer: My Awesome Team
args:
DEBIAN_FRONTEND: noninteractive
expose:
"3000": ""
entrypoint:
exec:
- node
- /app/app.js
runs:
commands:
- echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommends
modules:
- name: build-app
type: shell
source:
type: git
url: https://github.com/mirkobrombin/node-sample
branch: main
commit: latest
commands:
- mv /sources/build-app /app
- cd /app
- npm i
- npm run build
This image uses a single module to build a Node.js application from a Git
repository. The application is then installed and built using
npm
.
Then it exposes the port
3000
and sets the entrypoint to
node
/app/app.js
.
This recipe demonstrates how to compile Vib from source using a Vib recipe. While this looks like a dumb idea, it's a great way to learn how to use Vib.
name: my-recipe
id: my-go-app
stages:
- id: build
base: debian:sid-slim
labels:
maintainer: My Awesome Team
args:
DEBIAN_FRONTEND: noninteractive
runs:
commands:
- echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommends
modules:
- name: update
type: shell
commands:
- apt update
- name: vib
type: go
source:
type: git
url: https://github.com/vanilla-os/vib
branch: main
commit: latest
buildVars:
GO_OUTPUT_BIN: /usr/bin/vib
modules:
- name: golang
type: apt
source:
packages:
- golang
- ca-certificates
This recipe goes a step further by using three different modules, where two of them are nested. Basically we have the following modules:
update
is a simple
shell
module that updates the package list of the system.
vib
is a
go
module that compiles Vib from source. There are some important details
here:
source
is a
git
source that points to the Vib repository, Vib will automatically clone
the repository and place it in the
project/sources
directory. We are explicitly specifying the
branch
and
commit
to obtain the latest version of Vib.
buildVars
is a map of environment variables that will be used during the build
process. In this case, we are setting the
GO_OUTPUT_BIN
variable to
/usr/bin/vib
, which means
that the Vib binary will be placed
in the
/usr/bin
directory of the image. Vib will pass these variables to the build
process.
modules
is a list of modules that will be executed in the context of the
go
module. These takes precedence over the top-level modules.
golang
is an
apt
module that installs the
golang
and
ca-certificates
packages. Vib converts these instructions into apt commands, also it
will ask for a cleanup as the final step, to ensure apt removes any
unnecessary packages no longer required.
Learn more about the structure of Vib recipes and how to use them.