Templates and Blocks

based completely on Twig

Let's imagine you have multiple variants ready to be used by Orca.
Now you start to realize that you have lots of duplicate scripts that could be shared across all your tags, or even across multiple images.

This is when the Twig templating engine comes int play!


Building a global template

We start with this sample.
Our project has 1 image with 2 tags.

  • 📁 variants - folder for your images and variants
    • 📁 my_app
      • 📁 prod
        • 📄 Dockerfile
      • 📁 dev
        • 📄 Dockerfile

Let's create a new folder for our global template and simply call it "template".
Now add a new file in there and name it Dockerfile.sh.twig.

Here's the content of our file:


Now go back the Docker files of your variants and rename both to Dockerfile.sh.twig.
In addition to this, change their code to inherit from our new template file.


Great!
We can now adjust both our tags individually.

In this sample, we simply skip the installation of our dev tools in the production tag.
Just keep the block empty in the prod variant, while adding installation scripts in your dev variant.


Generate your files with Orca!

Congratulations, you have just created 2 individual and independent sources for building docker images from 1 single Orca source base.

If you want to know more about creating templates and blocks, we'll recommend visiting the Twig website and go through their documentation.