.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/podman/stable
16
17
    script:
        - cd prime
Nane Kratzke's avatar
Nane Kratzke committed
18
19
20
        - podman version
        - podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
        - podman build -t $CI_REGISTRY_IMAGE/prime:$VERSION -t $CI_REGISTRY_IMAGE/prime:latest .
Nane Kratzke's avatar
Nane Kratzke committed
21
22
        - podman push docker://$CI_REGISTRY_IMAGE/prime:$VERSION
        - podman push docker://$CI_REGISTRY_IMAGE/prime:latest
Nane Kratzke's avatar
Nane Kratzke committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#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
38

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

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

60
prime-service:
61
62
63
64
65
66
    stage: deploy
    image: 
        name: $KUBECTL
        entrypoint: [""]
    script:
        - echo "Deploying to Kubernetes"
Nane Kratzke's avatar
Nane Kratzke committed
67
        - 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
68
69
        - ./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
70
        - cat deploy/service/prime-ingress.yaml
Nane Kratzke's avatar
Nane Kratzke committed
71
72
        - kubectl delete -f deploy/service -n $NAMESPACE || true
        - kubectl apply -f deploy/service -n $NAMESPACE
73

74