.gitlab-ci.yml 1.21 KB
Newer Older
1
2
variables:
  KUBECTL: "bitnami/kubectl:1.18.9"
Nane Kratzke's avatar
Nane Kratzke committed
3
  NAMESPACE: "arne-jan-salveter"
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

Nane Kratzke's avatar
Nane Kratzke committed
27
prime:
28
29
30
31
32
33
34
35
36
    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 \
Nane Kratzke's avatar
Nane Kratzke committed
37
38
                    --docker-username=image-registry \ 
                    --docker-password=$CI_REGISTRY_TOKEN \ 
39
                    -n $NAMESPACE"
40
        - kubectl apply -k deploy/overlays/dev -n $NAMESPACE
41

42