Examples of Vib Recipes

Learn to use Vib through these simple recipe examples.

Node.js App

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.

Compile Software from Source

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:

Ready to Go Deeper?

Learn more about the structure of Vib recipes and how to use them.

More Examples Read the Docs