forked from sureshmaram/flask_docker_lab
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
437 additions
and
420 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
* text=auto | ||
*.sh text eol=lf | ||
*.yml text eol=lf | ||
*.yaml text eol=lf | ||
*.tf text eol=lf | ||
*.tfvars text eol=lf | ||
*.json text eol=lf | ||
*.py text eol=lf | ||
*.html text eol=lf | ||
*.txt text eol=lf | ||
*.example text eol=lf | ||
*.md text eol=lf | ||
*.template text eol=lf | ||
|
||
*.png binary | ||
*.jpg binary | ||
*.enc binary |
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,66 +1,66 @@ | ||
#### flask_docker_lab | ||
|
||
This is a basic Flask web application that will be deployed to AWS ECS using docker | ||
|
||
1. github account setup | ||
- Create a new github account (if you dont already have one) | ||
- fork repository flask_docker_lab github.com/peterb154/flask_docker_lab | ||
2. travis-ci account setup | ||
- Create a new travis-ci.org account if you don't already have one | ||
- link travis-ci to github | ||
- add your flask_docker_lab project | ||
3. AWS account setup | ||
- Create a new AWS free tier account if you don't already have one | ||
4. Setup developer workstation | ||
- Open AWS Console | ||
- Create EC2 Admin role | ||
- Launch AWS EC2 Developer AMI ami-<TBD> w/ admin role | ||
- Connect to AWS Developer Desktop Browser: http://<public_ip> pass: dockerlab | ||
or vnc to <public_ip>:5901 pass:dockerlab (easier) | ||
5. Download the code and make it your own | ||
- git config --global user.email "[email protected]" | ||
- git config --global user.name "Your Name" | ||
- git clone http://github.com/${user}/flask_docker_lab | ||
- cd flask_docker_lab | ||
6. Check out the application locally | ||
- docker-compose up | ||
- Browser: http://localhost:5000 | ||
- change something | ||
- validate change in browser | ||
6. Configure AWS Infrastructure using terraform | ||
- cd ./infrastructure | ||
- ssh-keygen | ||
- terraform init | ||
- terraform plan | ||
- terraform apply | ||
7. Build the .travis.yml | ||
- cd ../ | ||
- #TODO: create an example travis.yml | ||
- cp ./infrastructure/travis.yml.example .travis.ci | ||
- travis login # (enter github username and password) | ||
- ./create_ecr_secrets.sh # create a secrets file and encrypt it | ||
8. Tag and push our code | ||
- git tag -a v1.0 -m "the first version of our application" | ||
- git push origin v1.0 | ||
- Check travis-ci.org | ||
- Check AWS ECR repository | ||
9. Induce an error | ||
- git tag -a v1.1 -m "the second version of our application" | ||
- edit ./app/config.py to induce a link error | ||
{'title':'Bad Link','url':'http://something.wrong'}, | ||
- git add . | ||
- git commit -am "added a bad page" | ||
- git push --tags | ||
- Check out travis-ci.org - notice that the linktest failed | ||
- confirm in AWS ECR that new version was not deployed | ||
10. Fix the error | ||
- git tag -a v1.2 -m "the third version of our application" | ||
- edit ./app/config.py to fix error | ||
{'title':'Good Link','url':'http://www.google.com'}, | ||
- git add . | ||
- git commit -am "changed to a good page" | ||
- git push --tags | ||
- Check out travis-ci.org build process, confirm it succeeded | ||
- Check out AWS ECR, see new version 1.2 was created! | ||
11. Deploy our application to production | ||
- ... | ||
#### flask_docker_lab | ||
|
||
This is a basic Flask web application that will be deployed to AWS ECS using docker | ||
|
||
1. github account setup | ||
- Create a new github account (if you dont already have one) | ||
- fork repository flask_docker_lab github.com/peterb154/flask_docker_lab | ||
2. travis-ci account setup | ||
- Create a new travis-ci.org account if you don't already have one | ||
- link travis-ci to github | ||
- add your flask_docker_lab project | ||
3. AWS account setup | ||
- Create a new AWS free tier account if you don't already have one | ||
4. Setup developer workstation | ||
- Open AWS Console | ||
- Create EC2 Admin role | ||
- Launch AWS EC2 Developer AMI ami-<TBD> w/ admin role | ||
- Connect to AWS Developer Desktop Browser: http://<public_ip> pass: dockerlab | ||
or vnc to <public_ip>:5901 pass:dockerlab (easier) | ||
5. Download the code and make it your own | ||
- git config --global user.email "[email protected]" | ||
- git config --global user.name "Your Name" | ||
- git clone http://github.com/${user}/flask_docker_lab | ||
- cd flask_docker_lab | ||
6. Check out the application locally | ||
- docker-compose up | ||
- Browser: http://localhost:5000 | ||
- change something | ||
- validate change in browser | ||
6. Configure AWS Infrastructure using terraform | ||
- cd ./infrastructure | ||
- ssh-keygen | ||
- terraform init | ||
- terraform plan | ||
- terraform apply | ||
7. Build the .travis.yml | ||
- cd ../ | ||
- #TODO: create an example travis.yml | ||
- cp ./infrastructure/travis.yml.example .travis.ci | ||
- travis login # (enter github username and password) | ||
- ./create_ecr_secrets.sh # create a secrets file and encrypt it | ||
8. Tag and push our code | ||
- git tag -a v1.0 -m "the first version of our application" | ||
- git push origin v1.0 | ||
- Check travis-ci.org | ||
- Check AWS ECR repository | ||
9. Induce an error | ||
- git tag -a v1.1 -m "the second version of our application" | ||
- edit ./app/config.py to induce a link error | ||
{'title':'Bad Link','url':'http://something.wrong'}, | ||
- git add . | ||
- git commit -am "added a bad page" | ||
- git push --tags | ||
- Check out travis-ci.org - notice that the linktest failed | ||
- confirm in AWS ECR that new version was not deployed | ||
10. Fix the error | ||
- git tag -a v1.2 -m "the third version of our application" | ||
- edit ./app/config.py to fix error | ||
{'title':'Good Link','url':'http://www.google.com'}, | ||
- git add . | ||
- git commit -am "changed to a good page" | ||
- git push --tags | ||
- Check out travis-ci.org build process, confirm it succeeded | ||
- Check out AWS ECR, see new version 1.2 was created! | ||
11. Deploy our application to production | ||
- ... |
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,33 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# We want this script to exit if we get any errors | ||
set -e | ||
# This script pushes the built docker image to the repository | ||
|
||
# We should have secrets file created by create_ecr_secrets.sh, encoded | ||
# in the dev environment and decoded in the travis environment | ||
|
||
# Import the AWS ECR variables | ||
. ./ecr.secrets | ||
|
||
# Log into the AWS ECR repository | ||
echo "Loggin into repository ${ECR_URL}" | ||
docker login -u ${ECR_USER} -p ${ECR_PASS} ${ECR_URL} | ||
|
||
# Tag current build as latest | ||
echo "Tagging flask_docker_lab as ${ECR_DNS}/flask_docker_lab:latest" | ||
docker tag flask_docker_lab ${ECR_DNS}/flask_docker_lab:latest | ||
|
||
# Push this version as :latest | ||
echo "Pushing ${ECR_DNS}/flask_docker_lab:latest" | ||
docker push ${ECR_DNS}/flask_docker_lab:latest | ||
|
||
if [ ! -z ${TRAVIS_TAG} ]; then | ||
# Tag the image we built with the tag sent from github | ||
echo "\$TRAVIS_TAG is set to $TRAVIS_TAG" | ||
echo "Tagging ${ECR_DNS}/flask_docker_lab:latest as ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG}" | ||
docker tag ${ECR_DNS}/flask_docker_lab:latest ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG} | ||
|
||
# Now push the docker image again AWS ECR repository with version tag | ||
echo "Pushing ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG}" | ||
docker push ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG} | ||
fi | ||
#!/usr/bin/env bash | ||
# We want this script to exit if we get any errors | ||
set -e | ||
# This script pushes the built docker image to the repository | ||
|
||
# We should have secrets file created by create_ecr_secrets.sh, encoded | ||
# in the dev environment and decoded in the travis environment | ||
|
||
# Import the AWS ECR variables | ||
. ./ecr.secrets | ||
|
||
# Log into the AWS ECR repository | ||
echo "Loggin into repository ${ECR_URL}" | ||
docker login -u ${ECR_USER} -p ${ECR_PASS} ${ECR_URL} | ||
|
||
# Tag current build as latest | ||
echo "Tagging flask_docker_lab as ${ECR_DNS}/flask_docker_lab:latest" | ||
docker tag flask_docker_lab ${ECR_DNS}/flask_docker_lab:latest | ||
|
||
# Push this version as :latest | ||
echo "Pushing ${ECR_DNS}/flask_docker_lab:latest" | ||
docker push ${ECR_DNS}/flask_docker_lab:latest | ||
|
||
if [ ! -z ${TRAVIS_TAG} ]; then | ||
# Tag the image we built with the tag sent from github | ||
echo "\$TRAVIS_TAG is set to $TRAVIS_TAG" | ||
echo "Tagging ${ECR_DNS}/flask_docker_lab:latest as ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG}" | ||
docker tag ${ECR_DNS}/flask_docker_lab:latest ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG} | ||
|
||
# Now push the docker image again AWS ECR repository with version tag | ||
echo "Pushing ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG}" | ||
docker push ${ECR_DNS}/flask_docker_lab:${TRAVIS_TAG} | ||
fi |
Oops, something went wrong.