.gitlab-ci.yml 2.51 KB
Newer Older
ubuntu's avatar
ubuntu committed
1
2
3
4
5
6
7
8
9
10
11
image: gricad-registry.univ-grenoble-alpes.fr/kubernetes-alpes/buildah:latest

stages:
  - build
  - deploy

variables:
  REGISTRY_LOGIN: buildah login -u gitlab-ci-token -p $CI_REGISTRY_PASSWORD
  REGISTRY_LOGOUT: buildah logout
  IMAGE_BUILD: buildah build-using-dockerfile --storage-driver vfs --format docker
  IMAGE_PUSH: buildah push --storage-driver vfs
ubuntu's avatar
ini    
ubuntu committed
12
13
before_script:
  - $REGISTRY_LOGIN $CI_REGISTRY
ubuntu's avatar
ubuntu committed
14

ubuntu's avatar
ini    
ubuntu committed
15
16
after_script:
  - $REGISTRY_LOGOUT $CI_REGISTRY
ubuntu's avatar
ubuntu committed
17
18
19
20
21
22
23

docker build:
  stage: build
  variables:
    DOCKERFILE: Dockerfile
    IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  script:
ubuntu's avatar
ini    
ubuntu committed
24
    - echo "build stage"
ubuntu's avatar
ini    
ubuntu committed
25
          #  - $REGISTRY_LOGIN $CI_REGISTRY
ubuntu's avatar
ini    
ubuntu committed
26
27
          #- $IMAGE_BUILD --file $DOCKERFILE $BUILD_ARG --tag $IMAGE_NAME .
          #- $IMAGE_PUSH $IMAGE_NAME $IMAGE_NAME
ubuntu's avatar
ini    
ubuntu committed
28
      #  - $REGISTRY_LOGOUT $CI_REGISTRY
ubuntu's avatar
ubuntu committed
29
30
31
32
33
deploy:
  stage: deploy
  image: alpine/helm:latest
  variables:
    NAMESPACE: shiny
ubuntu's avatar
ini    
ubuntu committed
34
    RELEASE_NAME: $CI_PROJECT_NAME-$CI_PROJECT_ID
ubuntu's avatar
ini    
ubuntu committed
35
    #HOST:  "${RELEASE_NAME}.k.cirrus.cloud.inrae.fr"
ubuntu's avatar
ubuntu committed
36
    TLS_SECRET: rshiny-k-cirrus-cloud-inrae-fr-tls # this tls secret is valid for domainame *.k.cirrus.cloud.inrae.fr in shiny namespace
ubuntu's avatar
ini    
ubuntu committed
37
  before_script:
ubuntu's avatar
ini    
ubuntu committed
38
39
    - echo "project name is $CI_PROJECT_NAME"
    - echo "Release name is $RELEASE_NAME"
ubuntu's avatar
ini    
ubuntu committed
40
    - DOMAIN=${RELEASE_NAME}.k.cirrus.cloud.inrae.fr
ubuntu's avatar
ini    
ubuntu committed
41
    - export HOST=$( eval echo \$DOMAIN )
ubuntu's avatar
ini    
ubuntu committed
42
43
    - echo "Host is $HOST"
    - echo "Host is "
ubuntu's avatar
ini    
ubuntu committed
44
45
  script:
          #- helm init --client-only
ubuntu's avatar
ubuntu committed
46
    - helm create rshiny
ubuntu's avatar
ini    
ubuntu committed
47
48
    - 'sed -ri "s/^(\s*)(containerPort\s*:\s*80\s*$)/\1containerPort: 3838/" rshiny/templates/deployment.yaml'
    - 'sed -ri "s/^(\s*)(targetPort\s*:\s*http\s*$)/\1targetPort: 3838/" rshiny/templates/service.yaml'
ubuntu's avatar
ini    
ubuntu committed
49
      #- helm upgrade --namespace shiny --install rshiny-1 --set image.repository=rocker/shiny --set image.tag="3.6.1" --set serviceAccount.create=false --set serviceAccount.name=rshiny --set ingress.enabled=true --set ingress.hosts[0].host=rshiny-1.k.cirrus.cloud.inrae.fr --set ingress.hosts[0].paths[0].path="/" --set ingress.tls[0].secretName=rshiny-k-cirrus-cloud-inrae-fr-tls --set ingress.tls[0].hosts[0]=rshiny-1.k.cirrus.cloud.inrae.fr ./rshiny
ubuntu's avatar
ini    
ubuntu committed
50
    - helm upgrade --namespace $NAMESPACE --install $RELEASE_NAME --set image.repository=rocker/shiny --set image.tag="3.6.1" --set ingress.enabled=true --set ingress.hosts[0].host=$HOST --set ingress.hosts[0].paths[0].path="/" --set ingress.tls[0].secretName=$TLS_SECRET  --set ingress.tls[0].hosts[0]=$HOST ./rshiny
ubuntu's avatar
ini    
ubuntu committed
51

ubuntu's avatar
ini    
ubuntu committed
52
  after_script: 
ubuntu's avatar
ini    
ubuntu committed
53
     - 'echo "url to visit your application is https://rshiny-1.k.cirrus.cloud.inrae.fr"'