.gitlab-ci.yml 2.23 KB
Newer Older
1 2 3 4 5 6 7 8 9
image: openshift/origin-cli

default:
    tags:
       - debian
    timeout: 1h 00m

stages:
    - build
10
    - deploy
11 12 13 14 15

variables:
    OPENSHIFT_SERVER: https://${OPENSHIFT_IP}:${OPENSHIFT_PORT}/
    OPENSHIFT_DOMAIN: apps.okd.aip.de
# Configure this variable in Secure Variables:
16 17
#OPENSHIFT_TOKEN: see in OKD web interface (copy login cmd)
#OPENSHIFT_PROJECT: the name of the project
18 19 20 21 22 23

.login_to_okd: &login_to_okd
    - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify	
    - oc project "$CI_PROJECT_NAME-$CI_PROJECT_ID" 2> /dev/null || oc new-project "$CI_PROJECT_NAME-$CI_PROJECT_ID"

.build_image: &build_image
Yori Fournier's avatar
Yori Fournier committed
24
    - oc new-build --strategy=docker --binary --name "build-$APP" --to "image-$APP" --env-file="./docker/$APP/env"
25
    - oc start-build build-$APP --from-dir=./docker/$APP --follow 
26

Yori Fournier's avatar
Yori Fournier committed
27
pgapp:build:
28 29 30 31 32 33 34 35 36 37
    stage: build
    variables:
      APP: pgapp
      DOCKER_FILE: dockerfile
      APP_HOST: $CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
    before_script:
      - *login_to_okd
    script:
      - *build_image

Yori Fournier's avatar
Yori Fournier committed
38
pgdata:build:
39 40 41 42 43 44 45 46 47 48
    stage: build
    variables:
      APP: pgdata
      DOCKER_FILE: dockerfile
      APP_HOST: $CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
    before_script:
      - *login_to_okd
    script:
      - *build_image

Yori Fournier's avatar
Yori Fournier committed
49
wpdb:build:
50 51 52 53 54 55 56 57 58
    stage: build
    variables:
      APP: wpdb
      DOCKER_FILE: dockerfile
      APP_HOST: $CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$OPENSHIFT_DOMAIN
    before_script:
      - *login_to_okd
    script:
      - *build_image
59

Yori Fournier's avatar
Yori Fournier committed
60
pgapp:deploy:
61
    stage: deploy
Yori Fournier's avatar
Yori Fournier committed
62
    needs: ["pgapp:build"]
63 64 65
    before_script:
      - *login_to_okd
    script:
Yori Fournier's avatar
Yori Fournier committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
      - oc apply -f docker/pgapp/pgapp-deploy.yaml

pgdata:deploy:
    stage: deploy
    needs: ["pgdata:build"]
    before_script:
      - *login_to_okd
    script:
      - oc apply -f docker/pgdata/pgdata-deploy.yaml

wpdb:deploy:
    stage: deploy
    needs: ["wpdb:build"]
    before_script:
      - *login_to_okd
    script:
      - oc apply -f docker/wpdb/wpdb-deploy.yaml

#deploy:
#    stage: deploy
#    before_script:
#      - *login_to_okd
#    script:
#      - oc apply -f manifest.yaml
Yori Fournier's avatar
Yori Fournier committed
90
#      - oc new-app image-wpdb # this is working if one adds securityContext: runAsUser: 1000 in YAML file of deploymentConfig