From e24b96dbf26690ebe4afff0d667d8fd1f83d44f8 Mon Sep 17 00:00:00 2001 From: Bernardo Henrique Date: Tue, 2 Oct 2018 18:10:18 -0300 Subject: [PATCH] Config Deploy Co-authored-by: Felipe Hargreaves --- .travis.yml | 5 ++++- Dockerfile-prod | 15 +++++++++++++++ deploy.sh | 18 ++++++++++++++++++ requirements.txt | 3 ++- 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Dockerfile-prod create mode 100644 deploy.sh diff --git a/.travis.yml b/.travis.yml index dde723d..80410f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,7 @@ before_script: script: - docker-compose -f docker-compose-dev.yml run base python 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..14d3a7c --- /dev/null +++ b/Dockerfile-prod @@ -0,0 +1,15 @@ +# Base Image +FROM python:3.6.5-alpine + +# Setting working directory +WORKDIR /app + +# Dealing with requirements +COPY ./requirements.txt /app/requirements.txt +RUN pip install -r requirements.txt + +# Coping project +COPY . /app + +# Running server +CMD gunicorn -b 0.0.0.0:$PORT manage:app \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..93cd082 --- /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-gateway/web -f Dockerfile-prod . + +docker push registry.heroku.com/kalkuli-gateway/web + +heroku container:release web -a kalkuli-gateway \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index eea62de..45e0868 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ Flask-Testing==0.6.2 flask-cors==3.0.6 coverage==4.5.1 requests==2.19.1 -flasgger==0.9.1 \ No newline at end of file +flasgger==0.9.1 +gunicorn==19.8.1 \ No newline at end of file