- I'll use Vagrant to support my development work
- I'll use Docker as the mechanism for getting my projects hosted
- Start a project with a Vagrant set up file that will launch a Debian vm and apt-get Docker installed on it
- The Vagrant VM is used to build the code
- The result of of the development code is to build a Docker image of the project
- The Docker image is what is then used to deliver the project's services
As an example I created vagrant-docker-flask on GitHub to show how this works.
- Clone the git repo: git clone https://github.com/davegoopot/vagrant-docker-flask.git
- In the cloned directory run: vagrant up
- You now have the dev machine image installed that you can connect to using: vagrant ssh
- Inside vagrant run: cd /vagrant/flaskserver/
- Then build the flask server image with: sudo docker build -t="local:flask" .
- Start up a container from the image with: sudo docker run -d -p 5000:5000 local:flask python demo.py
- The flask server will run and be accessible from the original host machine at http://localhost:5000/
- To work on the code, you can now edit flask/demo.py, run the docker build and the docker run command again and see your changes
No comments:
Post a Comment