Jenkins and Docker for native Linux packages

Preview:

Citation preview

Building native Linux packages with Docker &

Jenkins

Whoami

Daniel Paulus

Open Source Consultant @ inuits.eu

Twitter/Github @dpnl87

Should start writing again @ danielpaulus.com

Background

Started with a nice Python application

Just `git clone` and have fun

Works fine on my machine!

Questions

What version of python?

Did you build your own or used system package?!

Any extra packages? Virtualenv?

How about a settings file?

Why not push Docker to production?

I need Native packages!

There is a book on writing RPMs! An effing book!

If you don’t have the time to read it use FPM!

If you do read the book: http://www.rpm.org/max-rpm/

From push to package

We are Jenkins power users

Use the pipeline plugin

Separate jobs as much as possible

Add a package job and push to repo

Wait a DEB?! We run everything on CentOS..

Docker to the rescue

CoreOS build slaves

Modern, minimal base.

Consumes 50% less RAM than an average Linux.

Jenkins slave needs Javamkdir /home/core/java

wget -O java.tar.gz http://javadl.sun.com/latest

tar xzvf java.tar.gz

rm /home/core/.bashrc

echo 'export PATH=$PATH:/home/core/java/jre1.7.0_51/bin/' > /home/core/.bashrc

Building the container

FROM ubuntu:14.04

RUN \

apt-get update && \

apt-get -y upgrade && \

apt-get install -y build-essential && \

We need FPM

RUN \

apt-get install -y ruby1.9.3 \

ruby-dev libssl-dev && \

gem install fpm --no-ri --no-rdoc

Actual build script#!/bin/bash

cd /root

fpm \ -s python \ --python-pip /usr/local/bin/pip \ --depends python-hell \ -t deb \ awesome-python-application

cat source/requirements.txt | xargs -L1 -n1 fpm -s python --python-pip /usr/local/bin/pip -t deb

ls python-* | xargs -L1 -n1 dpkg --info | grep Depends | awk '{for(i=1;i<=NF;i++){ tmp=match($i,"python-"); if(tmp) { sub("python-","",$i); sub(",", "", $i) ; print $i }}}'| sort | uniq | xargs -L1 -n1 fpm -s python --python-pip /usr/local/bin/pip -t deb

Dependencies? | Bash hell?

Artifact

eb548833ba525bd4f8c296759f8894c8 python-awesome-python-application-1-1.x86_64.rpm

pulp-admin rpm repo uploads rpm --repo-id private-builds --file /home/dpaulus/python-awesome-python-

application-1-1.x86_64.rpm

pulp-admin rpm repo publish run --repo-id= private-builds

The power of Chef

yum_repository ‘private-yum-repo‘ do description “private-yum-repo“ baseurl “http://www.inuits.eu/yum/stable/“ action :createend

package 'python-awesome-python-application' do action :upgrade end

Meetup!http://www.meetup.com/ Benelux-Chef-Meetup

Friday, September 18, 2015 9:30 AM to 5:00 PM

Schuberg Philis Boeing Avenue 271, Schiphol-Rijk

Recommended