-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Docker image building and pushing to Travis
- Loading branch information
Showing
4 changed files
with
80 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,57 @@ | ||
language: python | ||
|
||
python: | ||
- "3.6" | ||
|
||
install: | ||
# Install conda | ||
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh | ||
- bash miniconda.sh -b -p $HOME/miniconda | ||
- export PATH="$HOME/miniconda/bin:$PATH" | ||
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);' | ||
- conda clean --all -y | ||
- ./python_env_build.sh | ||
- source activate pb_env | ||
- python manage.py collectstatic --no-input | ||
|
||
addons: | ||
postgresql: "9.4" | ||
|
||
before_script: | ||
- psql -c 'create database test_db;' -U postgres | ||
|
||
script: | ||
- py.test webapp/apps/ | ||
matrix: | ||
include: | ||
- language: ruby # Cannot be 'minimal' in order to have PostgreSQL | ||
|
||
sudo: required | ||
|
||
services: docker | ||
|
||
env: TAG=${TRAVIS_COMMIT::6} | ||
|
||
# Need NEW_RELIC_TOKEN to be defined in Travis settings | ||
install: | ||
- make NEW_RELIC_TOKEN=$NEW_RELIC_TOKEN webapp-build | ||
- pip install --user git-lint pylint pycodestyle | ||
- export PATH=$PATH:/$HOME/.local/bin | ||
|
||
addons: | ||
postgresql: "9.4" | ||
|
||
before_script: psql -c 'create database mypb;' -U postgres | ||
|
||
script: | ||
- > | ||
docker run --net host -e PORT=80 -e DJANGO_SETTINGS_MODULE=webapp.settings | ||
-e DROPQ_WORKERS=127.0.0.1:5050 | ||
-e DATABASE_URL=postgresql://postgres@localhost/mypb | ||
-it opensourcepolicycenter/web:$TAG | ||
/bin/bash -c "pip install -q pytest-django && py.test webapp/apps" | ||
- if git reset --soft ${TRAVIS_COMMIT_RANGE%...*}; then git lint; fi | ||
|
||
before_deploy: curl https://cli-assets.heroku.com/install.sh | sh | ||
|
||
deploy: | ||
provider: script | ||
# Need HEROKU_TOKEN to be defined in Travis settings | ||
script: docker login --username=_ --password=$HEROKU_TOKEN registry.heroku.com && make MODE=test webapp-release | ||
on: | ||
branch: travis | ||
|
||
- language: minimal | ||
|
||
sudo: required | ||
|
||
services: docker | ||
|
||
# Also need OSPC_ANACONDA_TOKEN, AWS_ACCOUNT_ID, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to be defined in settings | ||
env: TAG=${TRAVIS_COMMIT::6} | ||
|
||
install: make OSPC_ANACONDA_TOKEN=$OSPC_ANACONDA_TOKEN dist-build | ||
|
||
script: make dist-test | ||
|
||
deploy: | ||
provider: script | ||
script: bash distributed/deploy.sh staging | ||
on: | ||
branch: travis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
mode=$1 | ||
region=us-east-2 | ||
|
||
pip install --user awscli | ||
eval $(aws ecr get-login --region $region --no-include-email) | ||
|
||
function tagpush() { | ||
docker tag opensourcepolicycenter/$1:$TAG $AWS_ACCOUNT_ID.dkr.ecr.$region.amazonaws.com/$mode-celeryflask:$1 | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$region.amazonaws.com/$mode-celeryflask:$1 | ||
} | ||
|
||
tagpush flask | ||
tagpush celery | ||
|
||
function redeploy() { | ||
aws ecs update-service --cluster $mode-ecs-cluster --service $mode-$1 --region $region --force-new-deployment >/dev/null 2>&1 | ||
} | ||
|
||
redeploy flask | ||
redeploy celery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters