Jenkins and Docker for native Linux packages
-
Upload
daniel-paulus -
Category
Technology
-
view
260 -
download
1
Transcript of Jenkins and Docker for native Linux packages
![Page 1: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/1.jpg)
Building native Linux packages with Docker &
Jenkins
![Page 2: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/2.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/3.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/4.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/5.jpg)
Why not push Docker to production?
![Page 6: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/6.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/7.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/8.jpg)
Wait a DEB?! We run everything on CentOS..
![Page 9: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/9.jpg)
Docker to the rescue
![Page 10: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/10.jpg)
CoreOS build slaves
Modern, minimal base.
Consumes 50% less RAM than an average Linux.
![Page 11: Jenkins and Docker for native Linux packages](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/11.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/12.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/13.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/14.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/15.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/16.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/17.jpg)
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](https://reader031.fdocuments.in/reader031/viewer/2022021813/587b4eb91a28abff1a8b55f5/html5/thumbnails/18.jpg)
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