This is a tool for internal use only! It is made public to easily test and integrate
The goal of the project is to spin up containers for different branches/versions
of a project by simply defining a .gcidp/build.go
file in the root directory of your project.
build.go
is a regular Go file where all the syntax and standard library works as expected.
You can run whatever code you want, starting from simple if
statements to complex pipelines.
The project also contains a set of utils to spin up docker containers, define build pipelines and many more features coming.
Your build.go
should contain the following code
var BuildServerVersion = "0.2.2" // this tells GCIDP server which version of the agent you are using
// At the moment server checks if the major versions match (0.2.x == 0.2.x), otherwise the build fails.
// Future iterations will include a more robust versioning system
func Cleanup(runner *pipeline.Runner) {
// this gets called when a branch is deleted
// your code here
}
func Build(runner *pipeline.Runner) {
// this gets called when a push to a branch is made
// your code here
}
You can define pipelines, a set of stages executed consecutively
runner.Pipeline(
// your stages go here
)
If you want to executed stages concurrently, define multiple pipelines
runner.Pipeline(
// your stages go here
)
runner.Pipeline(
// your stages go here
)
You can log messages to the UI using the Logger
runner.Logger.Debug("message")
runner.Logger.Info("message")
runner.Logger.Error("message")
You can define secrets in the UI and use them in your build file
v, err := runner.Secrets.Get("secretName")
if err != nil {
runner.Logger.Error(err.Error())
return
}
docker.Env("SECRET_API_KEY", v)
Building a docker image
docker.Build(imageName, contextDir).Target("prod"),
Running a docker container
docker.Run(containerName, imageName).Config(
docker.PortBinding("5432", "5432"),
docker.Volume("volumeName", "/var/lib/postgresql/data"),
docker.Env("POSTGRES_DB", "postgres"),
docker.Env("POSTGRES_PASSWORD", "postgres"),
docker.Network("app"),
)
Define environment variables
docker.Env("KEY", "VALUE")
Equivalent to
environment:
-KEY=VALUE
Define port bindings
docker.PortBinding("5432", "5432")
Equivalent to
ports:
- "5432:5432"
Define bind volume
docker.BindVolume("~/volumes/project/data", "/var/lib/postgresql/data")
Equivalent to
volumes:
- "~/volumes/project/data:/var/lib/postgresql/data"
Define named volume
docker.Volume("name", "/var/lib/postgresql/data")
Equivalent to
volumes:
- name:/var/lib/postgresql/data
Define networks
docker.Network("app")
Equivalent to
networks:
- app
Set hostname
docker.Hostname("postgres")
Equivalent to
db:
image: postgres
hostname: postgres