diff --git a/.travis.yml b/.travis.yml index 2532592..152a162 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,7 @@ before_script: script: - docker-compose -f docker-compose-dev.yml run base python3.6 manage.py test after_script: - - docker-compose -f docker-compose-dev.yml down \ No newline at end of file + - docker-compose -f docker-compose-dev.yml down +after_success: + - chmod +x ./deploy.sh + - ./deploy.sh \ No newline at end of file diff --git a/Dockerfile-prod b/Dockerfile-prod new file mode 100644 index 0000000..2605d1c --- /dev/null +++ b/Dockerfile-prod @@ -0,0 +1,26 @@ +# Our base image already includes tesseract. This should be the case only for +# this service. +FROM tesseractshadow/tesseract4re + +RUN mkdir /usr/src/app +WORKDIR /usr/src/app + +# Making sure we are using Python 3.6 +RUN add-apt-repository ppa:jonathonf/python-3.6 +RUN apt-get update +RUN apt-get install -y poppler-utils +RUN apt-get install -y python3.6 libpython3.6 + +RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 2 +RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 +RUN rm /usr/bin/python3 +RUN ln -s python3.6 /usr/bin/python3 + +RUN apt-get install -y python3-pip + +COPY ./requirements.txt /usr/src/app/requirements.txt +RUN pip3 install -r requirements.txt + +COPY . /usr/src/app + +CMD gunicorn -b 0.0.0.0:$PORT manage:app diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..ab9795f --- /dev/null +++ b/deploy.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e +set -u + +if [ $TRAVIS_PULL_REQUEST != "false" -o $TRAVIS_BRANCH != "master" ] +then + echo "Skipping deployment on branch=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST" + exit 0; +fi + +docker login -u _ -p "$HEROKU_TOKEN" registry.heroku.com + +docker build -t registry.heroku.com/kalkuli-extraction/web -f Dockerfile-prod . + +docker push registry.heroku.com/kalkuli-extraction/web + +heroku container:release web -a kalkuli-extraction \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 175f64c..54ea19b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ Pillow pytesseract opencv-python Flask-Testing==0.6.2 -coverage==4.5.1 \ No newline at end of file +coverage==4.5.1 +gunicorn==19.8.1 \ No newline at end of file