-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.gitlab-ci.yml
26 lines (23 loc) · 995 Bytes
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
image: docker:git
services:
- docker:dind
build:
stage: build
before_script:
# $CI_JOB_TOKEN is variable automatically added by Gitlab: see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token registry.gitlab.com --password-stdin
script:
- docker pull $GITLAB_IMAGE || true # Allows us to use --cache-from
- docker build --cache-from $GITLAB_IMAGE -t $GITLAB_IMAGE:$CI_COMMIT_SHA .
- docker push $GITLAB_IMAGE:$CI_COMMIT_SHA
deploy:
stage: deploy
before_script:
# Login to Gitlab registry
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token registry.gitlab.com --password-stdin
# Login to Google Cloud Registry
- echo $GOOGLE_CLOUD_ACCOUNT | docker login -u _json_key --password-stdin https://eu.gcr.io
script:
- docker pull $GITLAB_IMAGE:$CI_COMMIT_SHA
- docker tag $GITLAB_IMAGE:$CI_COMMIT_SHA $GCR_IMAGE:latest
- docker push $GCR_IMAGE