-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
97 lines (91 loc) · 3.28 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
stages:
# - base
- build
- deploy
variables:
DOCKER_HOST: "tcp://localhost:2375"
DOCKER_REGISTRY: "nexus.informatik.haw-hamburg.de"
cache:
paths:
- /usr/local/share/.cache/yarn
# this is the build image that is use for creating production and in development. It rarely changes
#build_deploy_base:
# stage: base
# services:
# - $DOCKER_REGISTRY/docker:stable-dind
# variables:
# SERVICE_NAME: "webui-svc-base"
# script:
# - docker login -u $NEXUS_USER -p $NEXUS_PW $DOCKER_REGISTRY
# - export DOCKER_HOST=$DOCKER_HOST
# - docker build -t $SERVICE_NAME:latest -f Dockerfile_base .
# - docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
# - docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:latest
# - docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
# - docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
# - docker push $DOCKER_REGISTRY/$SERVICE_NAME:latest
# - docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
# only:
# - master
build_dependencies:
stage: build
image: $DOCKER_REGISTRY/webui-svc-base
script:
- npm install --warn phantomjs-prebuilt # workaround for phantomjs being stupid
- yarn install --no-progress # npm in fast with cache :-)
- bower install --warn
- 'echo "{
\"pipelineId\": \"$CI_PIPELINE_ID\",
\"commitId\": \"$CI_COMMIT_SHA\"
}" > src/version.json'
- gulp # build dist/
- yarn install --no-progress --production # cleanup development packages
only:
- master
artifacts:
expire_in: 1 hour
paths:
- node_modules/
- dist/
cache:
paths:
- bower_components/
deploy_production:
stage: deploy
services:
- $DOCKER_REGISTRY/docker:stable-dind
variables:
SERVICE_NAME: "webui-svc"
script:
- docker login -u $NEXUS_USER -p $NEXUS_PW $DOCKER_REGISTRY
- mv node_modules/ node_modules_prod/ # fix some strange bug, where the name causes an issue.
- export DOCKER_HOST=$DOCKER_HOST
- docker build -t $SERVICE_NAME:latest .
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:latest
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:latest
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
only:
- master
deploy_development:
stage: deploy
services:
- $DOCKER_REGISTRY/docker:stable-dind
variables:
SERVICE_NAME: "webui-svc_dev"
script:
- docker login -u $NEXUS_USER -p $NEXUS_PW $DOCKER_REGISTRY
- rm -rf dist/
- export DOCKER_HOST=$DOCKER_HOST
- docker build -t $SERVICE_NAME:latest -f Dockerfile_dev .
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:latest
- docker tag $SERVICE_NAME:latest $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_PIPELINE_ID
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:latest
- docker push $DOCKER_REGISTRY/$SERVICE_NAME:$CI_COMMIT_SHA
only:
- master
dependencies: []