What is the best way to automate the deployment of a Docker image in a CI environment?
After building a simple web project using Travis CI and using a Dockerfile
to build the corresponding Docker image, is there a way to automatically cause that image to be deployed to a cloud provider?
Right now, the Dockerfile pulls down the base image to the Travis build machine and builds the image based on the instructions in the Dockerfile. At this point if the build is successful I can push it to the Docker Hub, though I have no need save this image to the Docker hub, what I envision is deploying the successfully built Docker image to a cloud provider (IE. DigitalOcean, Linode, or AWS) and starting/running the image.
Travis CI builds can run and build Docker images, and can also push images to Docker repositories or other remote storage.
Docker has become an early adopter in Continuous Integration and Continuous Deployment. By leveraging the right integration with source code control mechanism such as GIT, Jenkins can initiate a build process each time a developer commits his code.
Steps in a Build Pipeline Compiling code: in our case, that means compiling Java source code into class files. Executing tests: like running unit tests and possibly integration tests. Deploying artifacts: packaging complied code into artifacts, say into jar files, and deploying them.
Travis CI is an open-source hosted distributed continuous integration service used to build and test projects hosted at GitHub. Travis CI is configured by adding a file named .
While pushing directly to a host might seem ideal, I think it ignores the fact that hosts can fail, or may need to be replicated.
If you push directly to a prod host, and that host goes down, you don't have any way to start another one without re-running the entire CI pipeline.
If you push to an intermediary (the hub or a docker registry), you can create as many hosts as you want without having to re-run the build. You can also recover on a new host very easily (the initialize script can just pull the image and start).
If you wanted to, you could run your own registry on the cloud provider (instead of using the hub).
For a static website, you might want to look at Surge.
Otherwise, you might want to look at the AWS Elastic Beanstalk Command Line Interface (AWS EB CLI) in combination with using docker with AWS EB.
For using docker with AWS EB, read this AWS Blog post
For AWS EB CLI, here is an excerpt from the AWS EB dashboard sidebar
If you want to use a command line to create, manage, and scale your Elastic Beanstalk applications, please use the Elastic Beanstalk Command Line Interface (EB CLI). Get Started
$ mkdir HelloWorld $ cd HelloWorld $ eb init -p PHP $ echo "Hello World" > index.html $ eb create dev-env $ eb open
To deploy updates to your applications, use ‘eb deploy’.
Further reading
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With