### Services: コンテナイメージを複数扱う
servicesというキーワードを用いると、ベースイメージと接続可能なコンテナを定義できる
servies: - postgres:latest variables: POSTGRES_DB: custom_db POSTGRES_USER: ucstom_user POSTGRES_PASSWORD: custom_password
### Anchors
test1:
stage: test
image: python:latest
before_script:
- pipenv install --dev --system
script:
- pytest test1
test2:
state: test
image: python:latest
before_script:
- pipenv install --dev --system
script:
- pytest test2
.test_template: &test_definition
state: test
image: python:latest
before_script:
- pipenv install --dev --system
test1:
<<: *test_definition
script:
- pytest test1
test2:
<<: *test_definition
script:
- pytest test2
### 用意されているGitlab変数
build:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --pull -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
only:
- tags
### only and except
tagがpushされた時のみ
only:
– tags
ブランチがpushされた時は実行しない
except:
– master
あれ、Dockerfileではなく、gitlab.ymlにimageを書くの?