Guest User

Untitled

a guest
Nov 15th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. version: 2
  2. jobs:
  3. build:
  4. working_directory: /app
  5. docker:
  6. - image: docker:17.05.0-ce-git
  7. auth:
  8. #Put the contents of keyfile.json into an environment variable for the build called GCR_CREDS, which is then passed in.
  9. username: _json_key
  10. password: $GOOGLE_AUTH
  11. steps:
  12. - checkout
  13. - setup_remote_docker:
  14. # Requires this version to be able to use docker-compose
  15. version: 17.05.0-ce
  16. - run:
  17. name: Install dependencies
  18. command: |
  19. apk add --no-cache \
  20. py-pip=9.0.0-r1
  21. pip install \
  22. docker-compose==1.12.0
  23. - restore_cache:
  24. keys:
  25. - v1-{{ .Branch }}
  26. paths:
  27. - /caches/application.tar
  28. - run:
  29. name: Load Docker image layer cache
  30. command: |
  31. set +o pipefail
  32. docker load -i /caches/application.tar | true
  33. - run:
  34. name: Build application Docker image
  35. command: |
  36. # docker build --cache-from=application -t application .
  37. docker-compose -f ./docker-compose-test.yml build
  38. - run:
  39. name: Save Docker image layer cache
  40. command: |
  41. mkdir -p /caches
  42. docker save -o /caches/application.tar application
  43. - save_cache:
  44. key: v1-{{ .Branch }}-{{ epoch }}
  45. paths:
  46. - /caches/application.tar
  47. - run:
  48. name: Run tests
  49. command: |
  50. docker run -d -p 27017:27017 --network="bridge" app-db:latest
  51. docker run -d -p 6379:6379 --network="bridge" app-cache:latest
  52. docker run -p 9000:9000 --network="bridge" application:latest /opt/app/test.sh
  53. - run:
  54. name: Dump Google Cloud Credentials to file
  55. command: echo ${GOOGLE_AUTH} > ${HOME}/gcp-key.json
  56. - deploy:
  57. name: Push application Docker image
  58. command: |
  59. if [ "${CIRCLE_BRANCH}" == "master" ]; then
  60. echo "Deploying to Google Cloud...
  61. gcloud auth activate-service-account --key-file ${HOME}/gcp-key.json
  62. gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
  63. gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
  64. # gcloud --quiet container clusters get-credentials ${GOOGLE_CLUSTER_NAME}
  65. gcloud -q app deploy --project
  66. fi
Add Comment
Please, Sign In to add comment