version: 2 jobs: build: docker: - image: circleci/node:dubnium-browsers working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies2-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} # fallback to using the latest cache if no exact match is found - dependencies2- - run: yarn global add node-gyp && yarn install - run: yarn global add serve - run: yarn run build - run: yarn run test # - run: yarn run serve - save_cache: paths: - node_modules key: dependencies2-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} artifact-save: docker: - image: circleci/node:dubnium-browsers working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies2-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} # fallback to using the latest cache if no exact match is found - dependencies2- - run: yarn build - run: name: Copy deployment artifacts to workspace command: | cp ./dist /tmp/server -r - store_artifacts: path: /tmp/server - persist_to_workspace: root: /tmp paths: - server - save_cache: paths: - node_modules key: v1-dependencies2-{{ checksum "package.json" }} netlifly-deploy: docker: - image: circleci/node:dubnium-browsers working_directory: ~/repo steps: - checkout - restore_cache: keys: - dependencies2-{{ checksum "package.json" }}-{{ .Environment.CACHE_VERSION }} # fallback to using the latest cache if no exact match is found - dependencies2- - attach_workspace: at: /tmp - run: name: Deploy app command: sudo npm install netlify-cli -g && netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFLY_DEVOPSFINAL_TOKEN --prod --dir /tmp/server - save_cache: paths: - node_modules key: v1-dependencies2-{{ checksum "package.json" }} docker_build_push: working_directory: /dockerapp 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 $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD docker tag app $DOCKERHUB_USERNAME/dev_ops_front_container:$CIRCLE_BUILD_NUM docker tag app $DOCKERHUB_USERNAME/dev_ops_front_container:latest docker push $DOCKERHUB_USERNAME/dev_ops_front_container:$CIRCLE_BUILD_NUM docker push $DOCKERHUB_USERNAME/dev_ops_front_container:latest workflows: version: 2 build-deploy: jobs: - build - artifact-save: requires: - build - netlifly-deploy: requires: - build - artifact-save - docker_build_push: requires: - build