Yield generated for b848a7ac-fa4a-4be7-ac2d-d0c981854c8c
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

84 lines
3.0 KiB

# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
working_directory: ~/circleci-demo-python-django
docker: # run the steps with Docker
# CircleCI Python images available at: https://hub.docker.com/r/circleci/python/
- image: circleci/python:3.8.5
auth:
username: $DOCKER_HUB_USER_ID
password: $DOCKER_HUB_PWD # context / project UI env-var reference
environment: # environment variables for primary container
PIPENV_VENV_IN_PROJECT: true
DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
# CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/
- image: circleci/postgres:9.6.9-alpine
auth:
username: $DOCKER_HUB_USER_ID
password: $DOCKER_HUB_PWD # context / project UI env-var reference
environment: # environment variables for the Postgres container.
POSTGRES_USER: root
POSTGRES_DB: circle_test
steps: # steps that comprise the `build` job
- checkout # check out source code to working directory
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.8/site-packages
- restore_cache:
keys:
- v7-dependencies-{{ checksum "requirements/dev.txt" }}
- v7-dependencies-
- run:
command: |
export FLASK_APP=autoapp.py
pip install -r requirements/dev.txt --user
flask db upgrade
flask test
- save_cache:
paths:
- venv
key: v7-dependencies-{{ 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
environment:
CIRCLE_BUILD_NUM: 1
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
- back-deploy-heroku:
requires:
- build
- docker-build-and-push:
requires:
- back-deploy-heroku