forked from CERN/slides
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
75 lines (68 loc) · 2.19 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
variables:
FRONTEND_NAMESPACE_DEV: slides
BACKEND_NAMESPACE_DEV: slides-backend
# NAMESPACE: slides
OPENSHIFT_SERVER_DEV: https://openshift.cern.ch
# OPENSHIFT_SERVER: https://openshift.cern.ch
BUILD_ENV_DEV: staging
APP_NAME: slides
DEV_TAG: dev
stages:
- build_docker
- deploy
.docker_build_template: &docker_definition
stage: build_docker
image:
name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/$DOCKER_FILE --destination ${TO}
.deploy_template: &deploy_definition
stage: deploy
image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest
script:
- oc import-image ${APP_NAME} --from="${CI_REGISTRY_IMAGE}/${DEPLOYMENT_TYPE}:${TAG}" --confirm --token=${TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE} || true
- oc tag "${CI_REGISTRY_IMAGE}/${DEPLOYMENT_TYPE}:${TAG}" "${APP_NAME}:latest" --token=${TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE}
build_frontend_docker:
<<: *docker_definition
variables:
TO: ${CI_REGISTRY_IMAGE}/frontend:${DEV_TAG}
DOCKER_FILE: frontend.Dockerfile
only:
- master
build_backend_docker:
<<: *docker_definition
variables:
TO: ${CI_REGISTRY_IMAGE}/backend:${DEV_TAG}
DOCKER_FILE: backend.Dockerfile
only:
- master
deploy_frontend:
<<: *deploy_definition
variables:
TOKEN: ${OPENSHIFT_DEV_TOKEN}
OPENSHIFT_SERVER: ${OPENSHIFT_SERVER_DEV}
NAMESPACE: ${FRONTEND_NAMESPACE_DEV}
DEPLOYMENT_TYPE: frontend
TAG: ${DEV_TAG}
environment:
name: staging
url: https://slides.web.cern.ch
only:
- master
deploy_backend:
<<: *deploy_definition
variables:
# TOKEN: ${OPENSHIFT_DEV_TOKEN}
TOKEN: ${OPENSHIFT_DEV_BACKEND_TOKEN}
OPENSHIFT_SERVER: ${OPENSHIFT_SERVER_DEV}
NAMESPACE: ${BACKEND_NAMESPACE_DEV}
DEPLOYMENT_TYPE: backend
TAG: ${DEV_TAG}
environment:
name: staging
url: https://slides-backend.web.cern.ch
# url: https://backend-slides.app.cern.ch
only:
- master