The official Docker Hub provides an Automated Builds feature for consistent building of Docker images. Another possible use case for this service, which hasn't received as much attention, is Continuous Integration. Simply provide a Dockerfile for your project that runs tests during docker build. Docker Hub's integration with GitHub and Bitbucket will pick up new commits, run your tests, and generate new Docker images when tests are successful. Further, the service offers webhooks, which can be utilized to extend this use case into Continuous Deployment.
Dockerfile creates a Node.js environment for the sample project, then uses npm to install dependencies and run the project's tests during image creation. The image ENTRYPOINT and default command are set to npm start so docker run will default to launching the Node.js project within the container. Tests are run only once, during image creation, so all generated images are pre-certified and can be deployed and started without rerunning the tests
The remainder of the files in this repo provide an example Node.js project that responds to npm test and npm start
Copy Dockerfile into any Node.js project that responds to npm test and npm start
Update the ADD commands to include all project files needed for testing and running the app
To test with a local image, run docker build --tag="mynodeapp" .
To start the local image, run docker run -i -t -P mynodeapp
To use Docker Hub for CI, push the project and its Dockerfile to GitHub or BitBucket and configure your automated build
Consider using the webhooks feature to trigger deployments for successful builds
Tweet at me or File an issue if you have questions or comments. Suggestions or ideas for improvement are greatly appreciated.
Content type
Image
Digest
Size
247 MB
Last updated
over 9 years ago
docker pull visionarylabs/node-docker-ci