-
Notifications
You must be signed in to change notification settings - Fork 43
/
.gitlab-ci.yml
56 lines (51 loc) · 1.63 KB
/
.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
stages:
- test
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
.test:
stage: test
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
LINKED_SERVICE: "$TARGET:$TARGET"
script:
- docker pull "$CI_REGISTRY_IMAGE/base:$CI_COMMIT_BEFORE_SHA" || true
- docker pull "$CI_REGISTRY_IMAGE/$TARGET:$CI_COMMIT_BEFORE_SHA" || true
- docker build
--cache-from "$CI_REGISTRY_IMAGE/base:$CI_COMMIT_BEFORE_SHA"
--target base
--tag "$CI_REGISTRY_IMAGE/base:$CI_COMMIT_SHA"
.
- docker push "$CI_REGISTRY_IMAGE/base:$CI_COMMIT_SHA"
- docker build
--cache-from "$CI_REGISTRY_IMAGE/base:$CI_COMMIT_SHA"
--cache-from "$CI_REGISTRY_IMAGE/$TARGET:$CI_COMMIT_BEFORE_SHA"
--target "$TARGET"
--tag "$CI_REGISTRY_IMAGE/$TARGET:$CI_COMMIT_SHA"
.
- docker push "$CI_REGISTRY_IMAGE/$TARGET:$CI_COMMIT_SHA"
- docker run $([[ "$LINKED_SERVICE" != '' ]] && echo "--link=$LINKED_SERVICE") "$CI_REGISTRY_IMAGE/$TARGET:$CI_COMMIT_SHA"
tags:
- docker
test-sqlite:
extends: .test
variables:
TARGET: sqlite
LINKED_SERVICE: ''
test-mysql:
extends: .test
variables:
TARGET: mysql
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker run -d --name "$TARGET" -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:5
test-postgres:
extends: .test
variables:
TARGET: postgres
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker run -d --name "$TARGET" postgres:latest