Skip to content

beringresearch/bcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bravetools Configuration Language

BCL is a simplified configuration script for Bravetools Images.

  1. Installation
  2. Grammar
  3. Features
  4. Data Types
  5. Usage

Installation

git clone https://github.com/beringresearch/bcl
cd bcl
go get
go build
cp bcl /usr/local/bin

Grammar

The minimal structural unit of BCL is an Entry. Each Entry is comprised of functional Blocks. BCL supports five entry types:

  • base - describes base requirements for your image, such as base image and location of the image file.
image {
	name: "alpine/edge/amd64"
}
base {
  image: 	"alpine/edge/amd64"
  location:     "public"
}
  • system - describes system packages to be installed through a specified package manager. Supported package managers are atp and apk.
// Install bash and python3 using apk manager
system {
    apk:  ["bash", "python3"]
}
  • copy - is specialised entity designed for file and directory transfers between hosts and Brave Images. The Entity supports multible Blocks. Each Block must be prefaced with a key(e.g. Bravefile {...}) and contain a source and a target. Optionally, action specifies additional actions to perform once the file or directory has been copied to the image. All actions are executed on an image during build.
copy {
	Bravefile {
	source:			"Bravefile.bcl"
	target: 		"/root/Bravefile.bcl"
	action: 	 	"chmod 0700 /root/Bravefile.bcl"
	}

	Bravefile {
	source:			"Bravefile"
	target: 		"/root/Bravefile"
	action: 	 	"chmod 0700 /root/Bravefile"
	}

}
  • run - executes commands on the Brave image during build time. This Entity supports multiple Blocks and a diverse range of syntax. In its simplest embodiment, run Entity supports command, followed by an argument string. For example,
run {
  git: "clone https://github.com/beringresearch/bcl"
}

Complex strings are passed as Arrays.

run {
  echo: ["\"clone https://github.com/beringresearch/bcl\""]
}

This will print an output:

$ echo "clone https://github.com/beringresearch/bcl"
$ clone https://github.com/beringresearch/bcl

It is also possible to use Arrays to pass multiple complex commands.

run {
  bash: ["-c", "curl -sL https://bootstrap.pypa.io/get-pip.py | sudo -E python3.6"]
}

Multi-line strings are also supported:

run {
  echo: `\"This will generate a
multiline outout
to the terminal\"` 
}
  • service - controls image properties, such as name, version, and run-time configuration.
service {
	name:			"alpine"
	version:		"1.0"
	ip: 			"10.0.0.1"
	ports: 			"8008:8008"

	// Commands and actions to be run after unit is deployed
	postdeploy {
		copy {
			FileName {
			source:		"/file/or/directory"
			target: 	"/file/or/directory"
			action: 	 "chmod 0700 /file/or/directory"
			}
		}
		run {
			echo: 		"Hello World"
		}	
	}

	resources {
		ram: 		"4GB"
		cpu: 		2
		gpu:		true
	}
}

Features

Readability

BCL parser supports arbitrary TAB and SPACE placements. This can greatly improve readability:

system {
    apk:  ["bash", "python3",
           "htop", "curl"]
}

Comments

Comments are designated as // and are natively supported by the BCL parser.

// This entire entry will be ignored
//system {
//    apk: ["bash", "python3",
//          "htop", "curl"]
//}

Usage

Assuming that you have generated a BCL file Bravefile.bcl, to convert it to a conventional Bravefile run:

$ bcl Bravefile.bcl

The output will generate a Bravefile in the working directory.

About

Bering Configuration Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages