Public | Automated Build

Last pushed: 3 months ago
Short Description
Builds a Docker image from latest jenkins:alpine Docker image. Installs common DevOps tools.
Full Description

Jenkins DevOps Docker Image

Based on the latest jenkins:latest Docker image. Builds a new Docker image and installs common DevOps tools and Jenkins plugins, frequently used with Jenkins, including Git, AWS CLI, Terraform, Packer, Python, Docker, and jq.

This Jenkins containerized implementation is designed to be an ephemeral CI/CD DevOps tool - stood up, used, and torn down, ideal for the Cloud.

Installed Tools

Based on latest packages as of 6/2/2017 build:

Architecture

Fully configured, the Jenkins DevOps Docker container uses two bind-mounted directories on the host. The first, the Jenkins' home directory, contains all required configuration. The second directory is used for backups, created using the Jenkins Backup plugin. Additionally, Jenkins can back up its configuration, using the SCM Sync plugin, to GitHub. Both these backup methods require additional configuration.

Quick Start

Don't want to read the instructions?

sh ./stack_deploy_local.sh

Jenkins will be running on http://localhost:8083.

Optional: Adding Jenkins Plugins

The Dockerfile loads plugins from the plugin.txt. Currently, it installs two backup plugins. You can add more plugins to this file, before building Docker image. See the Jenkins Plugins Index for more.

thinBackup:1.9
backup:1.6.1

Optional: Create Docker Image

The latest garystafford/jenkins-devops image is available on Docker Hub.

Optionally, to create a new image from the Dockerfile

docker build -t garystafford/jenkins-devops:latest .

Run the Container

Create a new container from garystafford/jenkins-devops:latest image

sh ./stack_deploy_local.sh

Check logs

docker logs $(docker ps | grep jenkins-devops | awk '{print $1}')

This script also creates local directories /tmp/jenkins_home/.ssh/ and /tmp/jenkins_home/backups/.
All relevant Jenkins files are stored in bind-mounted /tmp/jenkins_home/ directory.
Backups are saved to the bind-mounted /tmp/jenkins_home/backups/ host directory, using the Jenkins' backup plugin.

Jenkins will be running on http://localhost:8083, by default.

SCM

Install scm-sync-configuration:0.0.10 plugin

Set git/GitHub repo path to your config repo, for example: git@github.com:<your_username>/jenkins-config.git

docker exec -it $(docker ps | grep jenkins-devops | awk '{print $1}') \
  bash -c 'git config --global user.email "<your@email.com>"'

docker exec -it $(docker ps | grep jenkins-devops | awk '{print $1}') \
  bash -c 'git config --global user.name "<your_username>"'

Optional: AWS SSL Keys

Copy any required AWS SSL key pairs to bind-mounted jenkins_home directory.

mkdir -p /tmp/jenkins_home/.ssh

# used for git SCM Sync plugin
cp ~/.ssh/id_rsa /tmp/jenkins_home/.ssh/id_rsa

# used for Consul cluster project
cp ~/.ssh/consul_aws_rsa* /tmp/jenkins_home/.ssh

Optional: AWS Credentials

Copy any required AWS credentials to bind-mounted jenkins_home directory

# used to connect to AWS with Packer/Terraform
cp ~/credentials/jenkins_credentials.env /tmp/jenkins_home/

Troubleshooting

Fix time skew with container time:

docker run -it --rm --privileged \
  --pid=host debian nsenter -t 1 -m -u -n -i \
  date -u $(date -u +%m%d%H%M%Y)

References

Docker Pull Command
Owner
garystafford
Source Repository

Comments (0)