A generic python/Flask app with a Docker file
- Install DockerToolbox (https://www.docker.com/toolbox)
- Install VirtualBox (https://www.virtualbox.org/wiki/Downloads)
- Open the newly installed "Docker" folder (in Applications for Mac)
- Click "Docker Quickstart Terminal"
- Run: docker pull heddle317/docker-flask-example
- Run: docker run -p 8080:80 -e ENVIRONMENT='production' -d --name=flask_app heddle317/docker-flask-example
- Run: VBoxManage controlvm default natpf1 "flask_app,tcp,127.0.0.1,8080,,8080"
- Go to localhost:8080 in your browser and you should see "Hello, world!"
- Fork this repository.
- Create an account at Dockerhub.com
- Click the "Create" dropdown in the far top right corner (not the "Create Repository+" button)
- Select "Create Automated Build"
- Link your Github (or Bitbucket) account, select your user, select the github repo, etc.
- Click the "Trigger a build" button, go to the "Build Details" tab and you should see a new build for your container.
- Clone your new repository down to your laptop
- Make a change to your Flask application (white space changes or comments are easy to test).
- Push your change to github.
- Go to your dockerhub account, click on your automated build repository, and click the build details tab.
- Once the build is finished, go to boot2docker.
- Run: docker pull [dockerHubUsername]/docker-flask-example (if you changed the name of the repo, reflect that here)
- Run: docker run -p 8080:80 -e ENVIRONMENT='production' -d --name=flask_app [dockerHubUsername]/[repoName]
- Go to localhost:8080 in your browser and you should see your application.
- Make an AWS account (if you don't have one).
- Create your own VPC (OPTIONAL: if you don't have one or want a new one).
- Create a new public subnet.
- Create an instance in your new public subnet.
- Ssh to your new machine: ssh -i aws.pem ec2-user@[instance-public-dns]
- Run: sudo yum update -y
- Run: sudo yum install -y docker
- Run: sudo service docker start
- Run (only necessary for private docker images): sudo docker login -e '[email]' -p '[password]' -u '[dockerHubUsername]'
- Run: sudo docker pull [dockerHubUsername]/[repoName]
- Run: sudo docker run -p 80:80 -e ENVIRONMENT='production' -d --name=flask_app [dockerHubUsername]/[repoName]
- Go to [instance-public-dns] to see your web app.
- If your laptop is not setup for python, follow these instructions (http://newcoder.io/pyladiessf/)
- Create a new virtualenv with venv or mkvirtualenv
- Run: pip install -r ./files/requirements.txt
- Create a keys.sh file with your sensitive information (e.g. export ENVIRONMENT='dev' and SECRET_KEY='')
- Run: ./run.sh web.py
- You should be able to see your application running on localhost:7010 (that port is configured in the app/config.py file)