Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/16-build-and-upload-docker-images-from-travis #17

Merged

Conversation

shanmukhananda
Copy link
Collaborator

…p.sh changes.

@shanmukhananda
Copy link
Collaborator Author

appveyor builds are failing because appveyor.yml is not present in this branch. This is part of PR13

@shanmukhananda
Copy link
Collaborator Author

DOCKER_USER and DOCKER_PASS are env vars added to Travis Settings

@shanmukhananda shanmukhananda changed the title travis now builds and uploads docker images on dockerfile or bootstra… feature/16-build-and-upload-docker-images-from-travis Nov 29, 2017
@shanmukhananda shanmukhananda force-pushed the feature/16-build-and-upload-docker-images-from-travis branch 2 times, most recently from 7abc3b6 to d25e4f8 Compare November 29, 2017 04:51
@paul-michalik
Copy link
Owner

Have you looked at the automated builds chapter on Docker Hub? Wouldn't it be better to set up something more robust with that? https://docs.docker.com/docker-hub/builds/#prerequisites

@shanmukhananda
Copy link
Collaborator Author

Yes I have tried docker hub's automated build, but there are issues with that.

  1. You need to have whole setup instructions written inside Dockerfile.
  2. Docker build context cannot be changed, mean Dockerfile should be at root folder
  3. Dockerhub's build will never copy dependent files like scripts/bootstrap.sh.
  4. They just copy Dockerfile and Readme.md in the root folder of github's project, other files like bootstrap.sh are not accessible
  5. Even if we solve above issues, docker automated build creates image on every commit if we link it to a github's repo

We need to upload docker images only if dockerfile or bootstrap.sh is changed.

@@ -0,0 +1,43 @@
#/bin/bash
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the intention but is this really necessary? Can't we make this a warning or maybe an error - if inconsistent bail out and make the build fail... I am a bit skeptical about the possible side effects...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If build fails it wont help the user much. User has to contact me and I need to build, test and upload new docker image to my account, which is cumbersome and might open window for errors in my side :-)

Almost every CI pipeline (travis, bitbucket pipeline, shippable, circle-ci, gitlab-ci etc) added support for automated docker build and upload. Many (like atlassin) encourage to use automatic build and upload of docker images. At-least the process wise I think it is correct to automate docker image deployment. We can always improve the conditions when the docker image is uploaded, what meta info is added, where it is upload etc in future.

Since the feature for continuous delivery of docker images in build servers is new feature, we dont see much github projects using it.

Useful links:
https://github.com/travis-ci/docs-travis-ci-com/blob/master/user/docker.md
http://docs.shippable.com/ci/push-docker-hub/
https://blog.bitbucket.org/2017/04/18/bitbucket-pipelines-supports-building-docker-images-and-service-containers/
https://circleci.com/docs/1.0/docker/

@@ -1,7 +1,9 @@
sudo: required
git:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which OS version is travis using? Can't we require Ubuntu 17 and use with the non-dockerized setup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis uses Ubuntu 14, it provides us with old tools like OpenCV2.4, gcc 4.8, cmake 3.5. Not much suitable for us. Ofcourse we can make it work but it requires few changes in cmake and may be in code if we are using latest c++. But I recommend current containerized build approach.

project_dir=${current_dir}/../..
cd ${project_dir}

$(git whatchanged HEAD^! | grep docker/Dockerfile > /dev/null)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What range of differences are considered here? How do we now that the user didn't create a new image? Or is this intended for travis usage only?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are currently looking at changes in HEAD^ which touched Dockerfile or the script. Is this sufficient? What I am missing is a last known state when the image was created. So I'd expect a range of commits starting at the known point where current image was created. This requires that this is somehow encoded in the image name or image metadata. Maybe "docker inspect" can help? Or tagging the image with current commit hash?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git whatchanged is used for travis purpose only. to check if a file is changed in the current commit.

User cannot upload a new image, Only I can upload a new image. travis pushes and pulls from my docker repository
Even if I upload some wrong image to docker hub. Travis uploads a new image if dockerfile/bootstrap.sh commit is on master.

Last state can be tracked, because we adding travis build number to docker image tag.
This has been explained in detail in below comment
#16 (comment)

@shanmukhananda shanmukhananda force-pushed the feature/16-build-and-upload-docker-images-from-travis branch from 5eb012b to e432176 Compare December 2, 2017 11:05
@shanmukhananda shanmukhananda force-pushed the feature/16-build-and-upload-docker-images-from-travis branch from 5e08ba2 to 2b6469d Compare December 2, 2017 11:41
@paul-michalik paul-michalik merged commit 6e59cdb into master Dec 4, 2017
@paul-michalik paul-michalik deleted the feature/16-build-and-upload-docker-images-from-travis branch December 4, 2017 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants