Reputation: 1177
I am writing a gitlab-ci.yml file to build images using packer and thereafter deploy them with terraform. Since I am new to gitlab, I thought it is possible to reference both Terraform and Packer images like so:
image:
name: registry.gitlab.com/gitlab-org/gitlab-build-images:terraform
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
image:
name: hashicorp/packer
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Upvotes: 1
Views: 3602
Reputation: 7695
You can only have one "default" image that is applied to every step in the pipeline, but you can specify an image to use for each job, or just the jobs that are different from the default.
From the GitLab CI documentation here (https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-image-and-services-from-gitlab-ciyml), you can specify a default for all steps to use:
default:
image: ruby:2.6
services:
- postgres:11.7
before_script:
- bundle install
test:
script:
- bundle exec rake spec
as well as have some steps differ from the default:
default:
image: ruby:2.6
services:
- postgres:11.7
before_script:
- bundle install
test: # this uses the default image
script:
- bundle exec rake spec
db_setup: # this uses a specific image that is different from the default
image: mysql:8
script:
- mysql -h my_datbase.example.com -u root -ppassword -e "create database my_database"
Upvotes: 2