# Python CircleCI 2.0 configuration file # # Check https://circleci.com/docs/2.0/language-python/ for more details # version: 2 jobs: build: docker: - image: circleci/python:3.7.4 steps: - checkout # Download and cache dependencies - restore_cache: keys: - v1-deps-{{ checksum "requirements/dev.txt" }} - v1-deps- # fallback to using the latest cache if no exact match is found - run: name: install dependencies command: | python3 -m venv venv . venv/bin/activate pip install -r requirements/dev.txt - save_cache: paths: - ./venv key: v1-deps-{{ checksum "requirements/dev.txt" }} test: docker: - image: circleci/python:3.7.4 environment: DATABASE_URL: postgresql://myUsr:somePwd@localhost:5432/myUsr - image: circleci/postgres:9.6.5 environment: POSTGRES_USER: myUsr POSTGRES_PASSOWRD: somePwd POSTGRES_DB: myUsr steps: - checkout - restore_cache: keys: - v1-deps-{{ checksum "requirements/dev.txt" }} - v1-deps- # fallback to using the latest cache if no exact match is found - run: name: bd upgrade command: | . venv/bin/activate sleep 1 flask db upgrade environment: CONDUIT_SECRET: 'something-really-secret' FLASK_APP: autoapp.py FLASK_DEBUG: 1 - run: name: flask test command: | . venv/bin/activate sleep 1 flask test environment: CONDUIT_SECRET: 'something-really-secret' FLASK_APP: autoapp.py FLASK_DEBUG: 1 - save_cache: paths: - ./venv key: v1-deps-{{ checksum "requirements/dev.txt" }} back-deploy-heroku: docker: - image: buildpack-deps:trusty steps: - checkout - run: name: Heroku Deploy command: git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git main docker-build-and-push: working_directory: /dockerapp docker: - image: docker:17.05.0-ce-git steps: - checkout - setup_remote_docker - run: name: build app for docker command: | docker build --cache-from=app -t app . - deploy: name: we publish the app on my docker hub command: | docker login -e $DOCKER_HUB_EMAIL -u $DOCKER_HUB_USER_ID -p $DOCKER_HUB_PWD docker tag app $DOCKER_HUB_USER_ID/backend_final:$CIRCLE_BUILD_NUM docker tag app $DOCKER_HUB_USER_ID/backend_final:latest docker push $DOCKER_HUB_USER_ID/backend_final:$CIRCLE_BUILD_NUM docker push $DOCKER_HUB_USER_ID/backend_final:latest workflows: version: 2 build-back-deploy: jobs: - build #- test: # requires: # - build - back-deploy-heroku: requires: - build - docker-build-and-push: requires: - back-deploy-heroku