Keep the build images DRY

This commit is contained in:
Andrew Newdigate 2017-08-08 17:58:52 +00:00 committed by Stan Hu
parent 2e43cb6259
commit 81d80aa564
17 changed files with 260 additions and 178 deletions

View file

@ -4,3 +4,58 @@ various parts of GitLab:
1. Build Omnibus packages
1. Test GitLab-CE/EE project
1. Build gitlab-org/www-gitlab-com project
# Adding a new image
There are two methods to adding a new image:
1. Use a docker buildfile
2. Use a custom image with versioned features
## Use a docker buildfile
A bespoke image is one that uses it's own Dockerfile. In the interests of
avoiding repetition, it's better to use the custom docker build if possible.
Assuming the image you want to add is called `new-image`....
1. Add a test task: `new-image test: *test_build`
1. Add a new build task: `new-image: *build_and_deploy`
1. Add a Dockerfile: `Dockerfile.new-image`
## Use a custom image with versioned features
To add a new image to the build, edit [`.gitlab-ci.yml`](https://gitlab.com/gitlab-org/gitlab-build-images/blob/master/.gitlab-ci.yml).
With custom images, the name of the image is used to define the contents (as opposed to use a bespoke Dockerfile build).
For this reason, the name needs to be correctly defined.
The name is defined as `[feature]-[version]` pairs, separated by `-`.
Here are some example build names:
1. `ruby-2.1-git-2.7-phantomjs-2.1`
1. `ruby-2.3.3-golang-1.8-git-2.7-chrome-60.0-node-7.1-postgresql-9.6`
1. `ruby-2.4.1-golang-1.8-git-2.7-phantomjs-2.1-node-7.1-postgresql-9.6`
The first pair represents the base image and version. So `ruby-2.1-...` will use the `ruby:2.1` base image, while
`golang-1.8` will use the `golang:1.8` base image.
Each of the following parts represents another feature and version. Available
options are:
1. `golang`
2. `git`
3. `chrome`
4. `node`
5. `phantomjs`
6. `postgres`
### Adding a new build
As an example, if you want to add new image for Ruby 2.4 with `git` 2.14 and `golang` 1.9,
the name would be `ruby-2.4-golang-1.9-git-2.14`.
1. Add a test task: `ruby-2.4-golang-1.9-git-2.14 test: *test_custom`
1. Add a new build task: `ruby-2.4-golang-1.9-git-2.14: *build_and_deploy_custom`