Local Continuous integration flow
User branch - pre-push git hook
A CI build process will be triggered by a User pre-push Git Hook. At the end of each build the CI pipeline status will be displayed on the Git repository (if you want, you can even stop user pushing code change if the CI process fails 🛑 )
Main branch - after merge
If the User branch or Pull request is ✅ , we can use Github or Bitbucket api for merging the code/Pull Request.
Once the Pr has been merged we can trigger an automatic CI pipeline on Main/Master branch.
How to run multiple parallel CI pipelines with Docker
First we should know how to create private sub-networks with Docker engine.
In Docker you can create multiple bridge networks.
Containers connected to the same user-defined bridge network effectively can resolve each other.
Using a user-defined network provides a scoped network in which only containers attached to that network are able to communicate.
Docker engine allows you to create multiple networks.
Example: we want max 254 parallel CI pipelines with max 126 containers for each network.
The Docker configuration will be:
- "Subnet": "172.20.X.0/24", // 172.20.X.1 - 172.20.X.254
- "IPRange": "172.20.X.0/25", // 172.20.X.1 - 172.20.X.126
- "Gateway": "172.20.X.12"
where 1 <= X <= 254
Single network configuration:
const availableNetwork = 1;
const networkConfig = {
"Subnet": `172.20.${availableNetwork}.0/24`,
"IPRange": `172.20.${availableNetwork}.0/25`,
"Gateway": `172.20.${availableNetwork}.12`
}
const networkOption = {
"Name": networkName,
"Driver": "bridge",
"Labels": {
"name": networkLabel
},
"IPAM": {
"Config": [networkConfig]
}
}
Article part 1: Git hooks and Docker for Continuous integration - part 1
Check LocalCI: localci.io
Top comments (0)