CircleCI, Dockerhub Demo
A demo project using
- GitHub as a repository manager with a write-protected master-branch and a PR-based workflow.
- CircleCi to "validate a website." On success you're allowed to merge your pull-request.
- Docker Hub automatically builds the latest master-branch and makes the image available.
TODO
- The Docker image should of course be tagged with a nice version.
Steps to reproduce
Create repository on Github
- Create a new repository on GitHub.
Subscribe project to CircleCI
- Visit https://circleci.com
- Under "Add Projects" find the new repository and click "Set Up Project".
- Click "Start Building"
In your working directory
- Add
config.yml to .circleci-folder with appropriate config,
valdiation, build, test-images etc.
git init
git add .
git commit -am "Initial commit"
git remote add origin [email protected]:<repository>.git
git push -u origin master
- Make a change to the repository and push to a
ready/setup branch.
Visit the CircleCI UI
- Go to
https://circleci.com/gh/<username>/<repository> in a browser,
you should have a job that's succeeded.
Otherwise keep making changes and pushing until you have a successful job; it registers as a ci/circleci: build status check on Github
Visit your repository on GitHub
-
Go to Settings -> Branches
-
Add a Branch Protection Rule for the master branch, choose
- Require status checks to pass before merging
- Require branches to be up to date before merging
- Select the
ci/circleci: build status check
- Include Administrators
-
Click "Create."
Add a Dockerfile
- Create a file called
Dockerfile with your image build logic
- (Optional) Create a file called
.dockerignore with a white/blacklist of all files that aren't relevant for your image
- Create a new commit, push this to a branch and create a pull-request. Don't merge it yet.
Create a new repository on Docker Hub
- Go to https://hub.docker.com/ and log in.
- Click "Create Repository"
- If you haven't already, link your GitHub to your Docker Hub.
- Give your new repository a name, and click "Create"
On your new repository, visit the "Builds" tab.
- Click on the "Link to GitHub" button.
- Select your organization and the repository you created earlier. Click "Save and Build."
It'll do an empty build on Docker Hub, because our master-branch doesn't yet contain a Dockerfile.
- (On GitHub) Merge your pull-request to the
master-branch.
- (On Docker Hub), A new build is triggered after a short while. (You may have to reload the page, to see the effect.)
After a little while your Docker Hub repository should be offering the latest image, the contents of the README.md on GitHub and the Dockerfile.