.gitlab-ci.yml 2.3 KB
Newer Older
1
variables:
Nane Kratzke's avatar
Nane Kratzke committed
2
  KUBECTL: "quay.io/bitnami/kubectl:1.18"
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"
Nane Kratzke's avatar
Nane Kratzke committed
6
  URL: "prime-nk.loki.th-luebeck.dev"
7
8

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

Nane Kratzke's avatar
Nane Kratzke committed
13
buildah-container:
14
    stage: build
Nane Kratzke's avatar
Nane Kratzke committed
15
    image: quay.io/buildah/stable
16
17
    script:
        - cd prime
Nane Kratzke's avatar
Nane Kratzke committed
18
        - buildah version
Nane Kratzke's avatar
Nane Kratzke committed
19
        - buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
Nane Kratzke's avatar
Nane Kratzke committed
20
        - buildah bud -t $CI_REGISTRY_IMAGE/prime:$VERSION -t $CI_REGISTRY_IMAGE/prime:latest .
Nane Kratzke's avatar
Nane Kratzke committed
21
22
23
        - buildah push $CI_REGISTRY_IMAGE/prime:$VERSION
        - buildah push $CI_REGISTRY_IMAGE/prime:latest

Nane Kratzke's avatar
Nane Kratzke committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        

#prime-container:
#    stage: build
#    services:
#        - mirror.gcr.io/docker
#    only:
#        changes:
#        - prime/*
#        - .gitlab-ci.yml
#    script:
#        - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
#        - cd prime
#        - docker build -t $CI_REGISTRY_IMAGE/prime:$VERSION -t $CI_REGISTRY_IMAGE/prime:latest .
#        - docker push $CI_REGISTRY_IMAGE/prime:$VERSION
#        - docker push $CI_REGISTRY_IMAGE/prime:latest
40

41
prime-storage:
42
    stage: prepare
43
44
45
46
47
48
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - kubectl apply -f deploy/storage -n $NAMESPACE

49
50
deploy-credentials:
    stage: prepare
51
52
53
54
55
56
57
    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 \
58
59
                    --docker-username=image-registry \ 
                    --docker-password=$CI_REGISTRY_TOKEN \
60
                    -n $NAMESPACE"
61

62
prime-service:
63
64
65
66
67
68
    stage: deploy
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - echo "Deploying to Kubernetes"
Nane Kratzke's avatar
Nane Kratzke committed
69
        - wget -q https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O ./yq && chmod +x yq
Nane Kratzke's avatar
Nane Kratzke committed
70
71
        - ./yq w -i deploy/service/prime-ingress.yaml spec.rules[0].host $URL
        - ./yq w -i deploy/service/prime-ingress.yaml spec.tls[0].hosts[0] $URL
Nane Kratzke's avatar
Nane Kratzke committed
72
        - cat deploy/service/prime-ingress.yaml
Nane Kratzke's avatar
Nane Kratzke committed
73
74
        - kubectl delete -f deploy/service -n $NAMESPACE || true
        - kubectl apply -f deploy/service -n $NAMESPACE
75

76