diff --git a/.circleci/config.yml b/.circleci/config.yml index 6713073..ac6485c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,86 +1,79 @@ - -executors: - node: - docker: - - image: circleci/node:8 - -aliases: - restore_cache: &restore_cache - restore_cache: - name: Restore Npm Package Cache - keys: - - yarn-cache-netlify-{{ checksum "yarn.lock" }} - - install_node_modules: &install_node_modules - run: - name: Install dependencies - command: yarn - - save_cache: &save_cache - save_cache: - name: Save NPM package cache - key: yarn-cache-netlify-{{ checksum "yarn.lock" }} - paths: - - ./node_modules - version: 2.1 - jobs: - test: - executor: node + install-dependencies: + docker: + - image: circleci/node:dubnium-browsers steps: - checkout - - <<: *restore_cache - - <<: *install_node_modules - - <<: *save_cache - - run: - name: Test - command: yarn test - + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} + - dependencies- + - run: yarn global add node-gyp && yarn install + - save_cache: + paths: + - node_modules + key: dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} build: - executor: node + docker: + - image: circleci/node:dubnium-browsers steps: - checkout - - <<: *restore_cache - - <<: *install_node_modules + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} + - dependencies- + - run: yarn build - run: - name: Build - command: yarn build + name: Copy deployment artifacts to workspace + command: | + cp dist/ /tmp/dist -r + - store_artifacts: + path: /tmp/dist - persist_to_workspace: - root: ./ + root: /tmp paths: - - public - - deploy: - executor: node + - dist + fondend-deploy: + docker: + - image: circleci/node:dubnium-browsers + working_directory: ~/dist steps: - - checkout - attach_workspace: - at: ./ - - <<: *restore_cache - - <<: *install_node_modules + at: /tmp - run: - name: Install netlify-cli - command: sudo npm install -g --silent netlify-cli - - run: - name: Deploy to Netlify - command: netlify deploy --dir=./public -p - + name: Deploy app + command: | + npx netlify-cli deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --dir /tmp/dist --prod + docker-buildandpush: + docker: + - image: docker:17.05.0-ce-git + steps: + - checkout + - setup_remote_docker + - run: + name: Build application Docker image + command: | + docker build --cache-from=app -t app . + - deploy: + name: Publish application to docker hub + command: | + docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PASSWORD + docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_APP:$CIRCLE_BUILD_NUM + docker tag app $DOCKER_HUB_USER_ID/$DOCKER_HUB_APP:latest + docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_APP:$CIRCLE_BUILD_NUM + docker push $DOCKER_HUB_USER_ID/$DOCKER_HUB_APP:latest workflows: - version: 2 - build_and_deploy: + version: 2.1 + build-deploy_frontend: jobs: - - test: - filters: - branches: - ignore: - - gh-pages + - install-dependencies - build: requires: - - test - - deploy: + - install-dependencies + - fondend-deploy: requires: - build - filters: - branches: - only: master + - docker-buildandpush: + requires: + - build \ No newline at end of file