1
+ language : php
2
+
3
+ dist : trusty
1
4
sudo : required
2
5
3
6
services :
@@ -9,20 +12,30 @@ cache:
9
12
- admin/node_modules
10
13
- client/node_modules
11
14
15
+ env :
16
+ global :
17
+ - APP_ENV=prod
18
+ - KUBERNETES_ENV=prod
19
+
20
+ before_install :
21
+ - |
22
+ if [ TRAVIS_BRANCH = "master" ] && [ $TRAVIS_REPO_SLUG = "api-platform/demo" ]; then
23
+ curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash -s -- --version v2.9.1;
24
+ else
25
+ KUBERNETES_ENV=staging;
26
+ exit 0;
27
+ fi
28
+
12
29
before_script :
13
30
- sudo service mysql stop
14
31
- sudo service postgresql stop
15
- - wget https://kubernetes-helm.storage.googleapis.com/helm-v2.6.1-linux-amd64.tar.gz
16
- - tar xzf helm-v2.6.1-linux-amd64.tar.gz
17
32
- npm install -g react-scripts
18
33
- while sudo lsof -Pi :5432 -sTCP:LISTEN -t; do sleep 1; done
19
34
20
35
script :
21
36
- docker-compose up -d
22
- - linux-amd64/ helm lint api/helm/api/
37
+ - helm lint api/helm/api/
23
38
- sleep 20
24
- - sh -c "cd admin && PUBLIC_URL="/api-demo-admin-test" yarn install && yarn build"
25
- - sh -c "cd client && PUBLIC_URL="/api-demo-client-test" yarn install && yarn build"
26
39
- docker-compose exec php composer install -o -n
27
40
- docker-compose exec php bin/console security:check
28
41
- docker-compose exec php bin/console doctrine:schema:validate --skip-sync
@@ -40,3 +53,33 @@ script:
40
53
- curl -k https://localhost:444
41
54
- curl -k https://localhost:8443
42
55
- curl -k https://localhost:8444
56
+
57
+ # TODO: Keep looking to https://github.com/kubernetes/kubernetes/pull/64034 as it is in an experimental state in order to use "wait" with new implementation (to replace sleep 60).
58
+ after_success :
59
+ - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
60
+ - chmod +x ./kubectl
61
+ - sudo mv ./kubectl /usr/local/bin/kubectl
62
+ - echo -n ${TRAVIS_SERVICE_ACCOUNT_KEY} | base64 -d > travis-service-account.json
63
+ - gcloud auth activate-service-account ${TRAVIS_SERVICE_ACCOUNT} --key-file travis-service-account.json --project=${PROJECT_NAME}
64
+ - gcloud config set compute/zone europe-west1-c
65
+ - gcloud config set project ${PROJECT_NAME}
66
+ - gcloud container clusters get-credentials api-platform-demo --zone europe-west1-c --project ${PROJECT_NAME}
67
+ - helm init --upgrade
68
+ - kubectl delete namespace $(kubectl get namespaces -l app=api-demo -o jsonpath="{.items[0].metadata.name}" --ignore-not-found) --ignore-not-found
69
+ - helm dependencies update ./api/helm/api
70
+ - docker build --pull -t eu.gcr.io/${PROJECT_NAME}/php -t eu.gcr.io/${PROJECT_NAME}/php:latest api --target api_platform_php
71
+ - docker build --pull -t eu.gcr.io/${PROJECT_NAME}/nginx -t eu.gcr.io/${PROJECT_NAME}/nginx:latest api --target api_platform_nginx
72
+ - docker build --pull -t eu.gcr.io/${PROJECT_NAME}/varnish -t eu.gcr.io/${PROJECT_NAME}/varnish:latest api --target api_platform_varnish
73
+ - gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/php:latest
74
+ - gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/nginx:latest
75
+ - gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/varnish:latest
76
+ - helm install --wait --namespace=${TRAVIS_COMMIT} ./api/helm/api --set php.repository=eu.gcr.io/${PROJECT_NAME}/php --set nginx.repository=eu.gcr.io/${PROJECT_NAME}/nginx --set varnish.repository=eu.gcr.io/${PROJECT_NAME}/varnish --set secret=${APP_SECRET} --set postgresUser=${DATABASE_USER},postgresPassword="${DATABASE_PASSWORD}",postgresDatabase=${DATABASE_NAME} --set postgresql.persistence.enabled=true --set corsAllowOrigin='*'
77
+ - sleep 60
78
+ - kubectl exec -it $(kubectl --namespace=${TRAVIS_COMMIT} get pods -l app=api-php -o jsonpath="{.items[0].metadata.name}") --namespace=${TRAVIS_COMMIT} -- ash -c 'export APP_ENV=dev && composer install -n && bin/console d:s:u --force --env=dev && bin/console hautelook:fixtures:load -n && APP_ENV=prod composer --no-dev install --classmap-authoritative && bin/console d:s:u --env=prod'
79
+ - kubectl label namespace ${TRAVIS_COMMIT} app=api-demo
80
+ - cd admin && REACT_APP_API_ENTRYPOINT=http://demo-admin.api-platform.com yarn build --environment=prod
81
+ - gsutil mb -l europe-west1 -p api-platform-demo gs://demo-admin.api-platform.com
82
+ - cd admin && gsutil cp -R build/* gs://demo-admin.api-platform.com/build
83
+ - gsutil iam ch allUsers:objectViewer gs://demo-admin.api-platform.com
84
+ - gsutil web set -m index.html gs://demo-admin.api-platform.com
85
+ - gcloud auth revoke ${TRAVIS_SERVICE_ACCOUNT}
0 commit comments