.gitlab-ci.yml 2.05 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
8
9
10

stages:
    - build
    - deploy

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

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

35
prime-dev:
36
37
38
39
40
41
42
43
44
    stage: deploy
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - echo "Deploying to Kubernetes"
        - kubectl delete secret gitlab-registry-credentials -n $NAMESPACE || true
        - "kubectl create secret docker-registry gitlab-registry-credentials \
                    --docker-server=$CI_REGISTRY \
45
46
                    --docker-username=image-registry \ 
                    --docker-password=$CI_REGISTRY_TOKEN \
47
                    -n $NAMESPACE"
Nane Kratzke's avatar
Nane Kratzke committed
48
        - kubectl delete -f deploy/dev -n $NAMESPACE || true
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
        - kubectl apply -f deploy/dev -n $NAMESPACE


prime-prod:
    only:
    - master
    stage: deploy
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - echo "Deploying to Kubernetes"
        - kubectl delete secret gitlab-registry-credentials -n $NAMESPACE || true
        - "kubectl create secret docker-registry gitlab-registry-credentials \
                    --docker-server=$CI_REGISTRY \
                    --docker-username=image-registry \ 
                    --docker-password=$CI_REGISTRY_TOKEN \ 
                    -n $NAMESPACE"
Nane Kratzke's avatar
Nane Kratzke committed
67
        - kubectl delete -f deploy/prod -n $NAMESPACE || true
68
        - kubectl apply -f deploy/prod -n $NAMESPACE
69

70