This repo contains an example of using Jenkins to build a simple tomcat app in Docker.
To use
- Install or otherwise get access to Jenkins.
- Create a docker secret with your docker login called docker-credentials. Alternately pass this as a Jenkin credential. "kubectl create secret docker-registry --docker-server= --docker-username= --docker-password= --docker-email= --dry-run -o yaml >docker-credentials.yaml" https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials
- Use the Jenkinsfile.kaniko or Jenkinsfile.img to create the pipeline and adjust the varibles in the environment section to match your app.
*To use a jenkins credential for docker repo access you will need to
- Remove the volume and volume mount section from the pod template.
- Define a Jenkins Cred for REGISTRY_PASSWORD, and define a variable REGISTRY_USER
- For Kaniko create a file /kaniko/.docker/config.json with user and password for your docker repo using your docker repo creds. Example '''echo "{"auths":{"$REGISTRY":{"username":"${REGISTRY_USER}","password":"${REGISTRY_PASSWORD}"}}}" > /kaniko/.docker/config.json'''
- For Img create /root/.docker/config.json as above or run "img login -u $REGISTRY_USER -p REGISTRY_PASSWORD $REGISTRY"
- Jenkinsfile.docker
A simple JenkinsfileDocker build for VMs and Docker in Docker (bad idea) - Jenkinsfile.img
A Jenkinsfile using img (see img-jenkins dir for building a Docker image for this.) https://github.com/genuinetools/img - Jenkinsfile.kaniko
A Jenkinsfile using Kaniko https://github.com/GoogleContainerTools/kaniko