18
Building native Linux packages with Docker & Jenkins

Jenkins and Docker for native Linux packages

Embed Size (px)

Citation preview

Page 1: Jenkins and Docker for native Linux packages

Building native Linux packages with Docker &

Jenkins

Page 2: Jenkins and Docker for native Linux packages

Whoami

Daniel Paulus

Open Source Consultant @ inuits.eu

Twitter/Github @dpnl87

Should start writing again @ danielpaulus.com

Page 3: Jenkins and Docker for native Linux packages

Background

Started with a nice Python application

Just `git clone` and have fun

Works fine on my machine!

Page 4: Jenkins and Docker for native Linux packages

Questions

What version of python?

Did you build your own or used system package?!

Any extra packages? Virtualenv?

How about a settings file?

Page 5: Jenkins and Docker for native Linux packages

Why not push Docker to production?

Page 6: Jenkins and Docker for native Linux packages

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/

Page 7: Jenkins and Docker for native Linux packages

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

Page 8: Jenkins and Docker for native Linux packages

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

Page 9: Jenkins and Docker for native Linux packages

Docker to the rescue

Page 10: Jenkins and Docker for native Linux packages

CoreOS build slaves

Modern, minimal base.

Consumes 50% less RAM than an average Linux.

Page 11: Jenkins and Docker for native Linux packages

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

Page 12: Jenkins and Docker for native Linux packages

Building the container

FROM ubuntu:14.04

RUN \

apt-get update && \

apt-get -y upgrade && \

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

Page 13: Jenkins and Docker for native Linux packages

We need FPM

RUN \

apt-get install -y ruby1.9.3 \

ruby-dev libssl-dev && \

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

Page 14: Jenkins and Docker for native Linux packages

Actual build script#!/bin/bash

cd /root

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

Page 15: Jenkins and Docker for native Linux packages

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?

Page 16: Jenkins and Docker for native Linux packages

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

Page 17: Jenkins and Docker for native Linux packages

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

Page 18: Jenkins and Docker for native Linux packages

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