Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
Signed-off-by: K.B.Dharun Krishna <[email protected]>
  • Loading branch information
kbdharun committed Apr 22, 2024
1 parent 63ed6f5 commit 07710d6
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 56 deletions.
15 changes: 8 additions & 7 deletions docs/articles/en/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description: How to start using Vib to build your Container images.
PublicationDate: 2024-02-11
Authors:
- mirkobrombin
- kbdharun
Tags:
- getting-started
---
Expand All @@ -14,7 +15,7 @@ Vib is a powerful tool that allows you to create container images using a YAML r

To use Vib, there are no specific requirements; you just need a Linux\* operating system (Mac OS and Windows will be supported in the future). Optionally, you can install a container engine to test and publish the images created to a registry.

\* Currently, Vib requires a Linux distribution with glibc.
\* Currently, Vib requires a Linux distribution with `glibc`.

### Supported Container Engines

Expand Down Expand Up @@ -45,17 +46,17 @@ mv vib ~/.local/bin

## Usage

To start using Vib, create a `vib.yaml` file in a new directory. This file will contain the recipe for your container image.
To start using Vib, create a `vib.yml` file in a new directory. This file will contain the recipe for your container image.

```bash
mkdir my-vib-project
cd my-vib-project
touch vib.yaml
touch vib.yml
```

Here's an example `vib.yaml` file:
Here's an example `vib.yml` file:

```yaml
```yml
name: My Image
id: my-image
stages:
Expand Down Expand Up @@ -102,13 +103,13 @@ vib build vib.yaml
to turn your recipe into a Containerfile. Use that file to build the container image with your container engine. To streamline the process, you can use the `compile` command to build the container image directly:

```bash
vib compile vib.yaml --runtime docker
vib compile vib.yml --runtime docker
```

changing `docker` with the container engine you have installed. Both `docker` and `podman` are supported. If you leave out the `--runtime` flag, Vib will use the default container engine giving priority to Docker.

> **Note:**
> For versions of Vib prior to 0.5.0, the syntax of the `compile` command was different. The `--runtime` flag was not available, and the command was `vib compile vib.yaml docker`.
> For versions of Vib before 0.5.0, the syntax of the `compile` command was different. The `--runtime` flag was not available, and the command was `vib compile vib.yml docker`.

The generated `Containerfile` is compatible with both Docker and Podman.

Expand Down
30 changes: 16 additions & 14 deletions docs/articles/en/github-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description: How to build a Vib image using GitHub Actions.
PublicationDate: 2024-02-14
Authors:
- mirkobrombin
- kbdharun
Tags:
- github
- build
Expand All @@ -13,7 +14,7 @@ Many projects use GitHub to host their code, and GitHub Actions to automate thei

## Setup the Workflow

To use the Vib GitHub Action, you need to create a workflow file in the repository where your Vib recipe is located. Create a new file in the `.github/workflows` directory, for example `vib-build.yml`, and add the following content:
To use the Vib GitHub Action, you need to create a workflow file in the repository where your Vib recipe is located. Create a new file in the `.github/workflows` directory, for example, `vib-build.yml`, and add the following content:

```yaml
name: Vib Build
Expand All @@ -30,9 +31,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: vanilla-os/vib-gh-action@v0.6.2
- uses: vanilla-os/vib-gh-action@v0.7.0
with:
recipe: "vib.yaml"
recipe: "vib.yml"
plugins: "org/repo:tag, org/repo:tag"

- name: Build the Docker image
run: docker image build -f Containerfile --tag ghcr.io/your_org/your_image:main .
Expand All @@ -46,18 +48,18 @@ Let's break down the workflow file:
- `runs-on`: The type of machine to run the job on. In this case, the job runs on the latest version of Ubuntu; check [here](https://github.com/actions/runner-images?tab=readme-ov-file#available-images) for the available machine types.
- `steps`: The sequence of tasks to run in the job.
- `actions/checkout@v4`: A standard action to check out the repository.
- `vanilla-os/vib-gh-action@v0.3.3-1`: The Vib GitHub Action to build the image. The `with` section specifies the recipe file to use.
- `run`: A standard command to build the Docker image. The `--tag` option specifies the name and tag of the image, in this case `ghcr.io/your_org/your_image:main`, you can change it according to your needs.
- `vanilla-os/vib-gh-action@v0.7.0`: The Vib GitHub Action to build the image. The `with` section specifies the recipe file and additional plugins to use.
- `run`: Contains a standard command to build the Docker image. The `--tag` option specifies the name and tag of the image, in this case, the tag is `ghcr.io/your_org/your_image:main`, you can change it according to your needs.

### Using Custom Plugins

If you are using custom Vib plugins in your recipe, you can include them in the workflow file. For example, if your plugin is named `my-plugin`, you can add the following step to the workflow file:

```yaml
# other steps
- uses: vanilla-os/vib-gh-action@v0.6.2
- uses: vanilla-os/vib-gh-action@v0.7.0
with:
recipe: "vib.yaml"
recipe: "vib.yml"
plugins: "your_org/my-plugin:v0.0.1"
# the rest of the workflow
```
Expand All @@ -72,10 +74,10 @@ To use more than one plugin, simply separate them with a comma:

```yaml
# other steps
- uses: vanilla-os/vib-gh-action@v0.6.2
- uses: vanilla-os/vib-gh-action@v0.7.0
with:
recipe: "vib.yaml"
plugins: "your_org/my-plugin:v0.0.1,another_org/another-plugin:v1.2.3"
recipe: "vib.yml"
plugins: "your_org/my-plugin:v0.0.1, another_org/another-plugin:v1.2.3"
# the rest of the workflow
```

Expand All @@ -102,16 +104,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: vanilla-os/vib-gh-action@v0.6.2
- uses: vanilla-os/vib-gh-action@v0.7.0
with:
recipe: "vib.yaml"
recipe: "vib.yml"
- name: Build the Docker image
run: docker image build -f Containerfile --tag ghcr.io/your_org/your_image .
run: docker image build -f Containerfile --tag ghcr.io/your_org/your_image:main .
# Push the image to GHCR (Image Registry)
- name: Push To GHCR
if: github.repository == 'your_org/your_image'
if: github.repository == 'your_org/your_repo'
run: |
docker login ghcr.io -u ${{ env.REGISTRY_USER }} -p ${{ env.REGISTRY_PASSWORD }}
docker image push "ghcr.io/your_org/your_image:main"
Expand Down
31 changes: 16 additions & 15 deletions docs/articles/en/project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ Description: How to structure your Vib project.
PublicationDate: 2024-02-13
Authors:
- mirkobrombin
- kbdharun
Tags:
- project
---

Vib only requires a `vib.yaml` file to build in the root of your project. However, to take full advantage of Vib, you can follow a specific project structure.
Vib only requires a `vib.yml` file to build in the root of your project. However, to take full advantage of Vib, you can follow a specific project structure.

## Standard Project

A project is a directory containing a `vib.yaml` file, this is the easiest way to use Vib in your existing projects, whatever their structure is. Then simply run `vib build` to build the image according to your recipe.
A project is a directory containing a `vib.yml` file, this is the easiest way to use Vib in your existing projects, whatever their structure is. Then simply run `vib build` to build the image according to your recipe.

The following is an example of a project structure:

```plaintext
my-project/
├── vib.yaml
├── vib.yml
```

## Vib Project
Expand Down Expand Up @@ -47,55 +48,55 @@ my-project/

### Structure Details

Here some details about the structure:
Here are some details about the structure:

- `vib/` is the directory containing the Vib project.
- `includes.container/` is the directory containing the files to be included in the image. It can contain any file or directory you want to include in the image. The files in this directory will be copied to the root of the image following the same structure.
- `modules/` is the directory containing the modules used in the recipes. You can create as many modules directories as you want, naming them as you prefer. Each module directory contains one or more YAML files, each one representing a module, name them as you prefer.
- `vib.yaml` is the recipe file for the image. You can have multiple `vib.yaml` files in the same project, each one representing a different image. For example, you can have a `dev.yaml` and a `prod.yaml` file to build different images for development and production environments, then build them with `vib build dev.yaml` and `vib build prod.yaml`.
- `vib.yml` is the recipe file for the image. You can have multiple `vib.yml` files in the same project, each one representing a different image. For example, you can have a `dev.yml` and a `prod.yml` file to build different images for development and production environments, then build them with `vib build dev.yml` and `vib build prod.yml`.

### Include Modules in the Recipe

You can define your modules directly in the recipe file but the above structure is recommended to keep the project organized and to reuse the modules across different recipes. So, once you have defined your modules directories, you can include them in the recipe file using the `include` module:

```yaml
```yml
- name: deps-modules
type: includes
includes:
- modules/node.yaml
- modules/python.yaml
- modules/node.yml
- modules/python.yml

- name: proj-modules
type: includes
includes:
- modules/myproject.yaml
- modules/myproject.yml
```
#### Remote Modules
Vib has support for remote modules, you can include them in the recipe file using the module URL or the `gh` pattern:

```yaml
```yml
- name: deps-modules
type: includes
includes:
- https://my-repo.com/modules/node.yaml
- gh:my-org/my-repo/modules/python.yaml
- https://my-repo.com/modules/node.yml
- gh:my-org/my-repo/modules/python.yml
```

As you can see in the above example, we are explicitly including each module in the recipe file and not pointing to the whole modules directory. This is because the `include` module ensure each module gets included in the exact order you specify, ensuring the build process is predictable.
As you can see in the above example, we are explicitly including each module in the recipe file and not pointing to the whole `modules` directory. This is because the `include` module ensures each module gets included in the exact order you specify, ensuring the build process is predictable.

### Usecase of the includes.container Directory

As mentioned, the `includes.container` directory contains the files to be included in the image. This directory is useful to include files that are not part of the project, for example, configuration files, desktop files, or any other file you want to include in the image.

This is useful expecially when you need to configure the Linux system with custom configuration files or new systemd services.
This is useful especially when you need to configure the Linux system with custom configuration files or new `systemd` services.

### Use the `adds` Directive

Optionally, you can use the `adds` directive to include more directories and files in the image:

```yaml
```yml
adds:
- extra-files/
- /etc/my-config-file
Expand Down
23 changes: 13 additions & 10 deletions docs/articles/en/recipe-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ Description: Learn about the structure of a Vib recipe.
PublicationDate: 2024-02-13
Authors:
- mirkobrombin
- kbdharun
Tags:
- modules
- recipe
---

> **Note**
> Stages were introduced in Vib v0.6.0, if you are using an older version, please keep in mind all the stage's fields are at the top level of the recipe, so no multiple stages are supported.
> Stages were introduced in Vib v0.6.0, if you are using an older version, please keep in mind all the stage fields are at the top level of the recipe, so no multiple stages are supported.
A Vib recipe is a YAML file that contains the instructions to build a container image. It's composed of two blocks:

Expand All @@ -19,7 +20,7 @@ A Vib recipe is a YAML file that contains the instructions to build a container

The following is a complete example of a Vib recipe:

```yaml
```yml
# metadata
name: My Image
id: my-image-id
Expand Down Expand Up @@ -60,7 +61,9 @@ stages:
singlelayer: false
labels:
maintainer: My Awesome Team
expose: 8080
expose:
"8080": "tcp"
"8081": ""
entrypoint: ["/app"]
copy:
- from: build
Expand All @@ -80,7 +83,7 @@ The metadata block contains the following mandatory fields:
- `base`: the base image to start from, can be any Docker image from any registry or even `scratch`.
- `name`: the name of the image.
- `id`: the ID of the image, can be used by platforms like [Atlas](https://images.vanillaos.org/#/) to identify the image.
- `id`: the ID of the image is used to specify an image's unique identifier, it is used by platforms like [Atlas](https://images.vanillaos.org/#/) to identify the image.
- `stages`: a list of stages to build the image, useful to split the build process into multiple stages (e.g. to build the application in one stage and copy the artifacts into another one).

## Stages
Expand All @@ -93,7 +96,7 @@ Each stage has the following fields:
- `labels`: a map of labels to apply to the image, useful to add metadata to the image that can be read by the container runtime.
- `adds`: a list of files or directories to add to the image, useful to include files in the image that are not part of the source code (the preferred way to include files in the image is to use the `includes.container/` directory, see [Project Structure](/docs/articles/en/project-structure)).
- `args`: a list of environment variables to set in the image.
- `runs`: a list of commands to run in the image (as an alternative to the `shell` module, useful for dividing the commands of your recipe from those needed to configure the image, for example to disable the recommended packages in apt).
- `runs`: a list of commands to run in the image (as an alternative to the `shell` module, useful for dividing the commands of your recipe from those needed to configure the image, for example, to disable the recommended packages in apt).
- `expose`: a list of ports to expose in the image.
- `cmd`: the command to run when the container starts.
- `entrypoint`: the entry point for the container, it's similar to `cmd` but it's not overridden by the command passed to the container at runtime, useful to handle the container as an executable.
Expand All @@ -104,21 +107,21 @@ Each stage has the following fields:

The modules block contains a list of modules to use in the recipe. Each module is a YAML snippet that defines a set of instructions. The common structure is:

```yaml
```yml
- name: name-of-the-module
type: type-of-the-module
# specific fields for the module type
```

Refer to the [Use Modules](/vib/en/use-modules) article for more information on how to use modules in a recipe and [Built-in Modules](/vib/en/built-in-modules) for a list of the built-in modules and their specific fields.

You can also write your own modules by making a Vib plugin, see the [Making a Plugin](/vib/en/making-plugin) article for more information.
You can also write your custom modules by making a Vib plugin, see the [Making a Plugin](/vib/en/making-plugin) article for more information.

### Copying files between stages

You can copy files between stages using the `copy` field. This consist in a list of files or directories to copy from another stage. Each item in the list is a YAML snippet that defines the source and destination of the copy operation. The common structure is:
You can copy files between stages using the `copy` field. This consists of a list of files or directories to copy from another stage. Each item in the list is a YAML snippet that defines the source and destination of the copy operation. The common structure is:

```yaml
```yml
- from: stage-id-to-copy-from
paths:
- src: /path/to/source
Expand All @@ -127,7 +130,7 @@ You can copy files between stages using the `copy` field. This consist in a list

For example, to copy the `/path/to/output` directory from the `build` stage to the `/app` directory in the `dist` stage, you can use the following snippet:

```yaml
```yml
- from: build
paths:
- src: /path/to/output
Expand Down
9 changes: 5 additions & 4 deletions docs/articles/en/use-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Description: How to use predefined and custom modules in your Vib recipes.
PublicationDate: 2024-02-13
Authors:
- mirkobrombin
- kbdharun
Tags:
- modules
---
Expand All @@ -13,7 +14,7 @@ Modules are a fundamental part of Vib, likely the thing you will interact with t
## Familiarize with Vib Recipes

> **Note**
> Stages were introduced in Vib v0.6.0, if you are using an older version, please keep in mind all the stage's fields are at the top level of the recipe, so no multiple stages are supported.
> Stages were introduced in Vib v0.6.0, if you are using an older version, please keep in mind all the stage fields are at the top level of the recipe, so no multiple stages are supported.
Before diving into the modules, it's important to understand the structure of a Vib recipe.

Expand All @@ -32,17 +33,17 @@ To get more information about the structure of a recipe and its fields, please r

A module is a YAML snippet that defines a set of instructions, the common structure is:

```yaml
```yml
name: name-of-the-module
type: type-of-the-module
# specific fields for the module type
```

While the `name` and `type` fields are mandatory, the specific fields depend on the module type. For example, a `shell` module has a `commands` field that contains the shell commands to execute to complete the task.

You will find that some modules has a common `source` field, this instructs Vib to download a resource required for the module to work:
You will find that some modules have a common `source` field, this instructs Vib to download a resource required for the module to work:

```yaml
```yml
- name: vanilla-tools
type: shell
source:
Expand Down
9 changes: 5 additions & 4 deletions docs/articles/en/vscode-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Description: Learn how to work with Vib recipes in Visual Studio Code using our
PublicationDate: 2024-02-14
Authors:
- mirkobrombin
- kbdharun
Tags:
- development
- vscode
---

Visual Studio Code is a popular code editor that provides a wide range of features to help you write, debug, and deploy your code, other than being highly customizable, it also offers a wide range of extensions to enhance your development experience, for example for working with YAML files.

Vib recipes are written in YAML, and usually a standard text editor or the YAML support provided by Visual Studio Code is enough to work with them. However, we have developed a dedicated extension for Visual Studio Code to make working with Vib recipes even easier and more efficient.
Vib recipes are written in YAML, and usually, a standard text editor or the YAML support provided by Visual Studio Code is enough to work with them. However, we have developed a dedicated extension for Visual Studio Code to make working with Vib recipes even easier and more efficient.

## Features

Expand All @@ -35,10 +36,10 @@ To install the Vib extension, follow these steps:

## Usage

Once the extension is installed, you can start using it to work with Vib recipes. For it to work, you need to put the following header at the beginning of your recipe:
Once the extension gets installed, you can start using it to work with Vib recipes. For it to work, you need to put the following header at the beginning of your recipe:

```yaml
```yml
# vib
```

This header is used to identify the file as a Vib recipe and to enable the extension features. In the future, we plan to have support for our own file extension, but for now, this is the way to go.
This header is used to identify the file as a Vib recipe and to enable the extension features. In the future, we plan to have support for our dedicated file extension, but for now, this is the way to go.
Loading

0 comments on commit 07710d6

Please sign in to comment.