FROM python:3.7
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT [ "python" ]
CMD [ "main.py" ]
web: gunicorn main:app
version: 2.1
orbs:
heroku: circleci/heroku@1.0.1
jobs:
build-and-test:
executor: heroku/default
docker:
- image: circleci/python:3.6.2-stretch-browsers
auth:
username: mydockerhub-user
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: Install Python deps in a venv
command: |
echo 'export TAG=0.1.${CIRCLE_BUILD_NUM}' >> $BASH_ENV
echo 'export IMAGE_NAME=python-circleci-docker' >> $BASH_ENV
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- run:
command: |
. venv/bin/activate
python -m pytest -v tests/test_script.py
- store_artifacts:
path: test-reports/
destination: tr1
- store_test_results:
path: test-reports/
- setup_remote_docker:
version: 19.03.13
- run:
name: Build and push Docker image
command: |
docker build -t $DOCKERHUB_USER/$IMAGE_NAME:$TAG .
docker login -u $DOCKERHUB_USER -p $DOCKER_HUB_PASSWORD_USER docker.io
docker push $DOCKERHUB_USER/$IMAGE_NAME:$TAG
deploy:
executor: heroku/default
steps:
- checkout
- run:
name: Storing previous commit
command: |
git rev-parse HEAD > ./commit.txt
- heroku/install
- setup_remote_docker:
version: 18.06.0-ce
- run:
name: Pushing to heroku registry
command: |
heroku container:login
#heroku ps:scale web=1 -a $HEROKU_APP_NAME
heroku container:push web -a $HEROKU_APP_NAME
heroku container:release web -a $HEROKU_APP_NAME
workflows:
build-test-deploy:
jobs:
- build-and-test
- deploy:
requires:
- build-and-test
filters:
branches:
only:
- main
pip freeze>requirements.txt
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin <github_url>
git push -u origin main
DOCKERHUB_USER
DOCKER_HUB_PASSWORD_USER
HEROKU_API_KEY
HEROKU_APP_NAME
HEROKU_EMAIL_ADDRESS
DOCKER_IMAGE_NAME=wafercircle3270303
git add .
git commit -m "proper message"
git push