Browse Source

🚀 deploy

main
MTLantoine 5 years ago
parent
commit
d8477fd433
  1. 25
      .circleci/config.yml

25
.circleci/config.yml

@ -1,8 +1,9 @@
version: 2
jobs: jobs:
install: install:
docker: docker:
- image: cimg/python:3.9.1
- image: circleci/postgres:9.6.2
- image: circleci/python:3.9.1
- image: circleci/postgres:9.6.5
environment: environment:
POSTGRES_DB: example POSTGRES_DB: example
POSTGRES_USER: circleci POSTGRES_USER: circleci
@ -15,10 +16,12 @@ jobs:
- restore_cache: - restore_cache:
keys: keys:
- dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }} - dependencies-{{ checksum "requirements/dev.txt" }}-{{ checksum "requirements/prod.txt" }}
# Fallback to using the latest cache if no exact match is found
- dependencies- - dependencies-
- run: - run:
name: Install dependencies name: Install dependencies
command: pip install -r requirements/dev.txt command: pip install -r requirements/dev.txt
# Upgrade dependencies for sqlalchemy and Flask-SQLAlchemy to pass unit tests
- run: - run:
command: pip install sqlalchemy --upgrade && pip install Flask-SQLAlchemy --upgrade command: pip install sqlalchemy --upgrade && pip install Flask-SQLAlchemy --upgrade
- run: - run:
@ -33,25 +36,23 @@ jobs:
FLASK_APP: /home/circleci/repo/autoapp.py FLASK_APP: /home/circleci/repo/autoapp.py
FLASK_DEBUG: 0 FLASK_DEBUG: 0
command: flask test command: flask test
deploy:
back-deploy-heroku:
docker: docker:
- image: buildpack-deps:trusty - image: buildpack-deps:trusty
steps: steps:
- checkout - checkout
- run: - run:
name: Heroku Deploy name: Heroku Deploy
command: git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD:main
command: git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD:main -f
- run: - run:
name: Smoke Test name: Smoke Test
command: | command: |
HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://devops-project-back.herokuapp.com/api/articles`
HTTPCODE=`curl -s -o /dev/null -w "%{http_code}" https://$HEROKU_APP_NAME.herokuapp.com/`
if [[ "$HTTPCODE" -ne 200 ]]; then if [[ "$HTTPCODE" -ne 200 ]]; then
echo "heroku app not responding, failing deploy" \ echo "heroku app not responding, failing deploy" \
exit 1; \ exit 1; \
fi fi
build-push:
docker-build-and-push:
docker: docker:
- image: docker:17.05.0-ce-git - image: docker:17.05.0-ce-git
steps: steps:
@ -69,16 +70,14 @@ jobs:
docker tag app $DOCKER_HUB_USER_ID/devops-project-back:latest docker tag app $DOCKER_HUB_USER_ID/devops-project-back:latest
docker push $DOCKER_HUB_USER_ID/devops-project-back:$CIRCLE_BUILD_NUM docker push $DOCKER_HUB_USER_ID/devops-project-back:$CIRCLE_BUILD_NUM
docker push $DOCKER_HUB_USER_ID/devops-project-back:latest docker push $DOCKER_HUB_USER_ID/devops-project-back:latest
version: 2.1
workflows: workflows:
version: 2 version: 2
devopsTP4:
build-test:
jobs: jobs:
- install - install
- deploy:
- back-deploy-heroku:
requires: requires:
- install - install
- build-push:
- docker-build-and-push:
requires: requires:
- install - install
Loading…
Cancel
Save