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

Jenkins Job should create and push a tomcat + web-app Docker Image #10

Closed
savishy opened this issue Aug 4, 2016 · 2 comments
Closed

Comments

@savishy
Copy link
Owner

savishy commented Aug 4, 2016

Instead of deploying the built WAR file as a post-build step, the Jenkins job should create a selfcontained image (tomcat + WAR) and push it to Docker Hub.

The playbook for tomcat should then pull from Docker Hub.

savishy added a commit that referenced this issue Aug 4, 2016
savishy added a commit that referenced this issue Aug 5, 2016
- to be able to execute docker commands docker client needs to be installed on jenkins docker container.
savishy added a commit that referenced this issue Aug 5, 2016
- added dependencies for installing docker build steps plugin into jenkins image.
- this plugin enables executing docker commands as build steps in jenkins jobs.
- configured the plugin.

NOTE: plugin is building image but tagging steps not working - WIP
savishy added a commit that referenced this issue Aug 5, 2016
added tomcat-users.xml with sample manager roles
savishy added a commit that referenced this issue Aug 5, 2016
- includes steps to build image, tag image and push image
savishy added a commit that referenced this issue Aug 5, 2016
- job config for petclinic-build now successfully builds an image and pushes it to Docker Hub.
- Docker Hub credentials need to be present in a credentials.xml file.
- Global Config file added for configuring Docker Daemon endpoint.
- Dockerfile modified to add these files to image
savishy added a commit that referenced this issue Aug 5, 2016
- to be able to docker push, a credentials is needed to be pre-stored in the jenkins container.
- I created a set of credentials (for docker hub) in Jenkins in the credentials module.
- this output a credentials.xml in JENKINS_HOME, which I then extracted.
- I am pushing this credentials XML into JENKINS_HOME while building the Jenkins image
- However, it seems the same encoding is not used everytime so the credentials.xml is not valid across Jenkins installations.
- i.e pulling this from one running Jenkins instance, then pushing it into a different instance does not seem to work.

As a result, docker push does not work unless you manually edit the credentials through UI before docker-pushing .

Notes:
- have tried using jenkins-cli. Could not figure out (despite trying for hours) how to use create-credentials-by-xml.
- have tried using the docker remote API call as well (curl -X POST /images/name/push). Encountering weird login issue.
@savishy
Copy link
Owner Author

savishy commented Aug 6, 2016

The "maven build" and "docker build" portions should be separated by means of a job, for logical separation of modules.

savishy added a commit that referenced this issue Aug 6, 2016
- maven step will pull directly from spring-projects/spring-petclinic github.
- after building and testing, petclinic WAR is the artifact of this job.
- downstream job is docker build. This uses copy artifact plugin to copy upstream artifact WAR into its workspace.
- then it takes care of building and pushing image (this part is still WIP, waiting on #11)

The advantage of this approach is I dont need to fork petclinic github and add a dockerfile to that project.
savishy added a commit that referenced this issue Aug 11, 2016
- curl POST to the docker API endpoint is successfully pushing docker images over AWS.
- (over local connection it seems to fail - possibly internet issues)
@savishy
Copy link
Owner Author

savishy commented Aug 11, 2016

With the fix of #11, this issue is also fixed.

@savishy savishy closed this as completed Aug 11, 2016
savishy added a commit that referenced this issue Aug 11, 2016
- made it independent so as to allow playbook to trigger each job (build WAR and build image) separately.
savishy added a commit that referenced this issue Aug 11, 2016
- working implementation of using curl -X POST and connecting to docker daemon on the host
- the daemon is contacted to push the docker image to hub
savishy added a commit that referenced this issue Aug 11, 2016
docker daemon running on the host needs the correct commandline options; so a modifed /etc/sysconfig/docker is needed
savishy added a commit that referenced this issue Aug 11, 2016
savishy added a commit that referenced this issue Aug 12, 2016
- the latest built image should be tagged with latest as well as the build number.
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

No branches or pull requests

1 participant