forked from mediathekview/mediathekviewweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
110 lines (96 loc) · 3.45 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
variables:
DOCKER_DRIVER: overlay2
DOCKER_BASH_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/common/docker-bash:latest"
DOCKER_BASH_IMAGE_SHA: "$CI_REGISTRY_IMAGE/common/docker-bash:$CI_COMMIT_SHA"
SERVER_DIST_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/server-dist:latest"
SERVER_DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/server-dist:$CI_COMMIT_SHA"
SERVER_DIST_IMAGE_BEFORE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/server-dist:$CI_COMMIT_BEFORE_SHA"
CLIENT_DIST_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/client-dist:latest"
CLIENT_DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/client-dist:$CI_COMMIT_SHA"
CLIENT_DIST_IMAGE_BEFORE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/client-dist:$CI_COMMIT_BEFORE_SHA"
DIST_IMAGE_LATEST: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest"
DIST_IMAGE_SHA: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA"
DIST_IMAGE_SHA_BEFORE: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_BEFORE_SHA"
DIST_IMAGE_DOCKER_HUB: "mediathekview/mediathekviewweb:latest"
DIST_IMAGE_DOCKER_HUB_DEVELOPMENT: "mediathekview/mediathekviewweb:development"
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- mkdir empty_dir
image: $DOCKER_BASH_IMAGE_LATEST
services:
- docker:dind
stages:
- build:dependencies
- build:application
- pack
- publish
build:docker-bash:
stage: build:dependencies
image: docker:stable
tags:
- docker
only:
variables:
- $BUILD_DOCKER_BASH == "true"
script:
- docker pull $DOCKER_BASH_IMAGE_LATEST || true
- docker build --pull -f ci/docker-bash.dockerfile --cache-from $DOCKER_BASH_IMAGE_LATEST --tag $DOCKER_BASH_IMAGE_SHA --tag $DOCKER_BASH_IMAGE_LATEST empty_dir
- docker push $DOCKER_BASH_IMAGE_LATEST
- docker push $DOCKER_BASH_IMAGE_SHA
build:server:
stage: build:application
tags:
- docker
except:
- schedules
script:
- bash ci/build-image.sh -f ci/server.dockerfile -c $SERVER_DIST_IMAGE_BEFORE_SHA -c $SERVER_DIST_IMAGE_SHA -n $SERVER_DIST_IMAGE_SHA -n $SERVER_DIST_IMAGE_LATEST .
build:client:
stage: build:application
tags:
- docker
except:
- schedules
script:
- bash ci/build-image.sh -f ci/client.dockerfile -c $CLIENT_DIST_IMAGE_BEFORE_SHA -c $CLIENT_DIST_IMAGE_SHA -n $CLIENT_DIST_IMAGE_SHA -n $CLIENT_DIST_IMAGE_LATEST .
pack:dist:
stage: pack
tags:
- docker
except:
- schedules
script:
- bash ci/build-image.sh -f ci/dist.dockerfile -a CLIENT_DIST_IMAGE=$CLIENT_DIST_IMAGE_SHA -a SERVER_DIST_IMAGE=$SERVER_DIST_IMAGE_SHA -c $DIST_IMAGE_SHA_BEFORE -c $DIST_IMAGE_SHA -n $DIST_IMAGE_SHA -n $DIST_IMAGE_LATEST empty_dir
- bash ci/extract-from-image.sh $DIST_IMAGE_SHA /mediathekviewweb dist
artifacts:
paths:
- dist
expire_in: 3 months
publish:image:
stage: publish
when: manual
tags:
- docker
only:
- master
except:
- schedules
script:
- docker pull $DIST_IMAGE_SHA
- docker tag $DIST_IMAGE_SHA $DIST_IMAGE_DOCKER_HUB
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD
- docker push $DIST_IMAGE_DOCKER_HUB
publish:image-development:
stage: publish
when: manual
tags:
- docker
only:
- development
except:
- schedules
script:
- docker pull $DIST_IMAGE_SHA
- docker tag $DIST_IMAGE_SHA $DIST_IMAGE_DOCKER_HUB_DEVELOPMENT
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD
- docker push $DIST_IMAGE_DOCKER_HUB_DEVELOPMENT