.gitlab-ci.yml 1.63 KB
Newer Older
1
2
variables:
  KUBECTL: "bitnami/kubectl:1.18.9"
Nane Kratzke's avatar
Nane Kratzke committed
3
  NAMESPACE: "nane-kratzke"
Nane Kratzke's avatar
Nane Kratzke committed
4
  VERSION: "0.0.1"
5
  BRANCH: "$CI_COMMIT_BRANCH"
6
7

stages:
8
    - prepare
9
10
11
    - build
    - deploy

Nane Kratzke's avatar
Nane Kratzke committed
12
prime-container:
13
14
15
16
17
18
19
20
21
22
    stage: build
    services:
        - docker:dind
    only:
        changes:
        - prime/*
        - .gitlab-ci.yml
    script:
        - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
        - cd prime
Nane Kratzke's avatar
Nane Kratzke committed
23
        - docker build -t $CI_REGISTRY_IMAGE/prime:$VERSION -t $CI_REGISTRY_IMAGE/prime:latest .
24
25
        - docker push $CI_REGISTRY_IMAGE/prime:$VERSION
        - docker push $CI_REGISTRY_IMAGE/prime:latest
26

27
prime-storage:
28
    stage: prepare
29
30
31
32
33
34
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - kubectl apply -f deploy/storage -n $NAMESPACE

35
36
deploy-credentials:
    stage: prepare
37
38
39
40
41
42
43
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - kubectl delete secret gitlab-registry-credentials -n $NAMESPACE || true
        - "kubectl create secret docker-registry gitlab-registry-credentials \
                    --docker-server=$CI_REGISTRY \
44
45
                    --docker-username=image-registry \ 
                    --docker-password=$CI_REGISTRY_TOKEN \
46
                    -n $NAMESPACE"
47

48
prime-service:
49
50
51
52
53
54
    stage: deploy
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - echo "Deploying to Kubernetes"
Nane Kratzke's avatar
Nane Kratzke committed
55
56
        - wget https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O ./yq && chmod +x yq
        - ./yq --help
Nane Kratzke's avatar
Nane Kratzke committed
57
58
        - kubectl delete -f deploy/service -n $NAMESPACE || true
        - kubectl apply -f deploy/service -n $NAMESPACE
59

60