-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
64 lines (59 loc) · 2.51 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
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
PX_WEB_CONFIG_MAP: spring-configmap
FILEBEAT_CONFIG_MAP: filebeat-config
DOCKER_PULL_SECRET: px-web-app-gitlab-docker-secret
IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
NAMESPACE: px-web-app-prod
#include:
# - template: Container-Scanning.gitlab-ci.yml
# - template: Dependency-Scanning.gitlab-ci.yml
# - template: License-Management.gitlab-ci.yml
docker_build:
image: docker:18.09
stage: build
services:
- docker:18.09-dind
script:
- apk add --update bash gettext tzdata coreutils
- docker info
- envsubst < config/.application.yml > config/application.yml
- docker build -t $IMAGE .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $IMAGE
when: manual
kube_deploy_prod_hh:
environment: prod-hh
extends: .kube_deploy_script
kube_deploy_prod_hx:
environment: prod-hx
extends: .kube_deploy_script
.kube_deploy_script:
stage: deploy
image: dtzar/helm-kubectl
script:
- apk add --update bash gettext tzdata coreutils
- export HOSTNAME_BCKUP=$HOSTNAME && export HOSTNAME='${HOSTNAME}'
- envsubst < config/.application.yml > config/application.yml
- envsubst < .filebeat.yml > filebeat.yml
- export HOSTNAME=$HOSTNAME_BCKUP
- mkdir -p ~/.kube
- echo $KUBE_CONFIG > kubeconfig
- base64 -d kubeconfig > ~/.kube/config
- kubectl config get-contexts
- kubectl create namespace $NAMESPACE || true
- kubectl -n $NAMESPACE delete secret $DOCKER_PULL_SECRET || true
- kubectl -n $NAMESPACE create secret docker-registry $DOCKER_PULL_SECRET --docker-server=$CI_REGISTRY --docker-username=$CI_DEPLOY_USER --docker-password=$CI_DEPLOY_PASSWORD
# create configmap for first time
- kubectl -n $NAMESPACE create configmap $PX_WEB_CONFIG_MAP --from-file=config/application.yml || true
# replace configmap if it already exists
- kubectl -n $NAMESPACE create configmap $PX_WEB_CONFIG_MAP --from-file=config/application.yml -o yaml --dry-run | kubectl replace -f -
# create configmap for first time
- kubectl -n $NAMESPACE create configmap $FILEBEAT_CONFIG_MAP --from-file=filebeat.yml || true
# replace configmap if it already exists
- kubectl -n $NAMESPACE create configmap $FILEBEAT_CONFIG_MAP --from-file=filebeat.yml -o yaml --dry-run | kubectl replace -f -
- envsubst < .kubernetes.yml > kubernetes.yml
- cat kubernetes.yml
- kubectl -n $NAMESPACE apply -f kubernetes.yml
when: manual