-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
80 lines (73 loc) · 2.08 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
variables:
WORK_DIR: ./
DOCKER_IMAGE_FRONT: $CI_REGISTRY/student-project-sep-hs-mannheim/greenbox-collective/frontend
DOCKER_IMAGE_BACK: $CI_REGISTRY/student-project-sep-hs-mannheim/greenbox-collective/backend
DOCKERFILE_PATH: $WORK_DIR/Dockerfile
VERSION: $CI_PIPELINE_ID
TAG: $CI_PIPELINE_ID
APP_FRONT: greenbox-hmc-frontend
APP_BACK: greenbox-hmc-backend
# TAG: $CI_COMMIT_REF_SLUG
stages:
- build
- docker
- deploy
build-frontend:
stage: build
image: node:latest
cache:
paths:
- ./frontend/node_modules/
before_script:
- npm --prefix ./frontend install
script:
- npm run --prefix ./frontend build
artifacts:
paths:
- ./frontend/dist
expire_in: 1 week
build-backend:
stage: build
image: java:8
script:
- cd ./backend && chmod a+x ./mvnw && ./mvnw package && cd -
artifacts:
paths:
- ./backend/target/hmc-backend.jar
expire_in: 1 week
docker:
stage: docker
image: docker:18.09.4
dependencies:
- build-frontend
- build-backend
services:
- docker:18.09.4-dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t $DOCKER_IMAGE_FRONT:$TAG ./frontend/
- docker build -t $DOCKER_IMAGE_BACK:$TAG ./backend/
- docker push $DOCKER_IMAGE_FRONT:$TAG
- docker push $DOCKER_IMAGE_BACK:$TAG
deploy:
stage: deploy
image: atolia/alpine-kubectl
environment:
name: greenbox
url: https://students.caruso.cf/
script:
- mkdir -p ~/.kube
- echo ${KUBECFG} | base64 -d > ~/.kube/config
- kubectl config get-contexts
- kubectl config use-context dev.caruso.cf
- sed 's|_APP_NAME_FRONT|'$APP_FRONT'|g; s|_DOCKER_IMAGE_NAME_FRONT|'$DOCKER_IMAGE_FRONT:$TAG'|g;' kubernetes.tpl.yml > kubernetes1.yml
- sed 's|_APP_NAME_BACK|'$APP_BACK'|g; s|_DOCKER_IMAGE_NAME_BACK|'$DOCKER_IMAGE_BACK:$TAG'|g;' kubernetes1.yml > kubernetes.yml
- kubectl delete -f kubernetes.yml || true
- kubectl create -f kubernetes.yml
artifacts:
paths:
- ./kubernetes.yml
expire_in: 1 week
only:
- master