SlideShare a Scribd company logo
Packaging a Python
application after you
messed up
Roman Prykhodchenko, Allegro
@romcheg
me@romcheg.me
November 2019, Warsaw
www.devopsdays.pl
DevOpsDays Warsaw 2019
• Maintained and used in house
• Heavily modified django-admin
• Python + HTML + JS
• Open-source + private extensions
• In house: Ubuntu + Docker image
• In community: mostly Ubuntu + deb package but....
DCIM system: Ralph
2
DevOpsDays Warsaw 2019
Problem
• Community builds are often broken
• Troubleshooting takes more time than we have
• No motivation to support the community
3
DevOpsDays Warsaw 2019
Reasons
• Two separate delivery pipelines
• TravisCI: Debian package built and published once a week
• Bamboo: Docker image with private extensions available on demand
• Different artefacts in community and local packages
• Supporting the community is not the team's #1 priority
4
DevOpsDays Warsaw 2019
Solution:
Improve the delivery pipeline by re-thinking packaging.
5
DevOpsDays Warsaw 2019
• ... a file with an .rpm or .deb in the end
• ... a python wheel
• ... a tarball with a source code and a Makefile
• ... a container image?! 0_o
Package is...
6
DevOpsDays Warsaw 2019
Package is a distributable set of idempotent alternations
bringing desired artefacts and state changes to a target
system.
7
DevOpsDays Warsaw 2019
Containerisation is a form of packaging – the rules apply.
8
DevOpsDays Warsaw 2019
Delivery pipeline
Source code
0 1 0
1 0 1
1 1 0
Build
toolchain
Artefacts
Build
dependencies
Runtime
dependencies
Packaging
toolchain
Package
9
DevOpsDays Warsaw 2019
Target platforms
MutableImmutable
• Artefacts
• Configuration
• Dependencies
• Artefacts
• Configuration
• List of
dependencies
Runtime
depencencies
Fetch
10
DevOpsDays Warsaw 2019
Target platforms
Runtime dependencies are
available in vendor repositories.
Runtime dependencies are
shipped within the package.
11
DevOpsDays Warsaw 2019
• Supporting the community was not #1 priority
12
DevOpsDays Warsaw 2019
Solution:
1. Create a single pipeline for the community and ourselves
2. Pack the same artefacts into different packages
13
DevOpsDays Warsaw 2019
Target platforms
14
DevOpsDays Warsaw 2019
0 1
1 0
0 1
1 0
15
DevOpsDays Warsaw 2019
• cPython 3.4+
• Database drivers + other shared libraries
• Required python libraries
• ...
• Django-*
Runtime dependencies
16
DevOpsDays Warsaw 2019
Deb package
Artefacts:
1. Python code
2. Static files
3. Configuration
Runtime dependencies:
1. python-3
2. mysql-common
3. ...
4. python3-mysql
5. python3-django
6. python3-*
17
DevOpsDays Warsaw 2019
Never run pip install on a target system.
18
DevOpsDays Warsaw 2019
• Copy dependencies to the source tree
• Keeping wheels in the source tree
• Package a virtual environment 0_o
• No source-code changes required
• Use standard management tools
• Gradual migration to system packages
Other options?
19
DevOpsDays Warsaw 2019
• Create one
• Install python stuff
• Required packages
• Source code
• Fix the symlinks
• Pack the virtualenv into the deb package
Virtualenv
20
DevOpsDays Warsaw 2019
dh_virtualenv does all of that for you!
debian/control:
21
DevOpsDays Warsaw 2019
dh_virtualenv does all of that for you!
debian/rules:
22
DevOpsDays Warsaw 2019
• Use all matching requirements from the vendor's
repository
• Use dh_virtualenv
• Put the rest of the requirements along with the source code into the
virtualenv
• Gradually migrate the code to the libraries available in the vendor's
repositories
Deb package – summary
23
DevOpsDays Warsaw 2019
Docker image – extra layer of complexity
• Supporting different container orchestrators
• Configuration without breaking immutability
• Performing operations without entering running containers
• Serving static files
24
DevOpsDays Warsaw 2019
• Single entry point script
• Avoid exposing the filesystem structure
• Acts like a facade for all entry points
• By default starts the service
Startup and operations
25
DevOpsDays Warsaw 2019
• Select few essential configuration options and define
environment variables for each
• The entry point script puts the values of those variables
into configuration files
• Those in need of supplying advanced configuration should mount the
entire configuration as a volume
Configuration
26
DevOpsDays Warsaw 2019
• Build a separate image with static files
• Use a lightweight image like nginx as a base
• Users will route requests to one of the containers depending
on the container orchestrator
Static files
27
DevOpsDays Warsaw 2019
• Custom entry point acting like a facade
• Essential configuration options as environment variables
• Advanced configuration is done by mounting configuration
as a volume
• Static files are available in a separate image
• Publish both images at the same time
Docker image – summary
28
DevOpsDays Warsaw 2019
Conclusion
29
DevOpsDays Warsaw 2019
Support opinionated scenarios based on in-house usage.
30
DevOpsDays Warsaw 2019
Improve things gradually.
31
DevOpsDays Warsaw 2019
Be ready to say goodbye to corner-case users to make
the vast majority happy.
32
DevOpsDays Warsaw 2019
Does not matter what decisions you make, unless they are
irreversible.
33
DevOpsDays Warsaw 2019
Thank you!
34
Roman Prykhodchenko, Allegro
@romcheg
me@romcheg.me
I'm waiting for
your feedback!
You can rate speakers and lectures
using our official conference app

More Related Content

What's hot

DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
Docker, Inc.
 
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & DockerWSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
WSO2
 
Microcontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container DebuggingMicrocontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container Debugging
Oracle Developers
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelines
DevOps.com
 
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC WongDocker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC WongDocker, Inc.
 
July OpenNTF Webinar - HCL Presents Keep, a new API for Domino
July OpenNTF Webinar - HCL Presents Keep, a new API for DominoJuly OpenNTF Webinar - HCL Presents Keep, a new API for Domino
July OpenNTF Webinar - HCL Presents Keep, a new API for Domino
Howard Greenberg
 
Docker Online Meetup #30: Docker Trusted Registry 1.4.1
Docker Online Meetup #30: Docker Trusted Registry 1.4.1Docker Online Meetup #30: Docker Trusted Registry 1.4.1
Docker Online Meetup #30: Docker Trusted Registry 1.4.1
Docker, Inc.
 
Docker Overview - AWS Tech Connect - Seattle 10/28
Docker Overview - AWS Tech Connect - Seattle 10/28Docker Overview - AWS Tech Connect - Seattle 10/28
Docker Overview - AWS Tech Connect - Seattle 10/28
Mike Coleman
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Google Developer Group Zürich
 
The Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With PuppetThe Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With Puppet
Mike Merideth
 
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
Lucas Jellema
 
Informix on Docker Hub
Informix on Docker HubInformix on Docker Hub
Informix on Docker Hub
Pradeep Natarajan
 
Using Docker in production: Get started today!
Using Docker in production: Get started today!Using Docker in production: Get started today!
Using Docker in production: Get started today!
Clarence Bakirtzidis
 
Introduction to Docker | Docker and Kubernetes Training
Introduction to Docker | Docker and Kubernetes TrainingIntroduction to Docker | Docker and Kubernetes Training
Introduction to Docker | Docker and Kubernetes Training
Shailendra Chauhan
 
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Docker, Inc.
 
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ....docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
ICON UK EVENTS Limited
 
IIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and DockerIIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and Docker
Pradeep Natarajan
 
DockerCon EU 2015 Barcelona
DockerCon EU 2015 BarcelonaDockerCon EU 2015 Barcelona
DockerCon EU 2015 Barcelona
Roman Dembitsky
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container world
zekeLabs Technologies
 
Docker Hub Breakout Session at DockerCon by Ken Cochrane
Docker Hub Breakout Session at DockerCon by Ken CochraneDocker Hub Breakout Session at DockerCon by Ken Cochrane
Docker Hub Breakout Session at DockerCon by Ken Cochrane
Docker, Inc.
 

What's hot (20)

DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
DockerCon EU 2015: Docker Universal Control Plane (Gordon's Special Session)
 
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & DockerWSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
WSO2Con ASIA 2016: Revolutionizing WSO2 App Cloud with Kubernetes & Docker
 
Microcontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container DebuggingMicrocontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container Debugging
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelines
 
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC WongDocker Hub: Past, Present and Future by Ken Cochrane & BC Wong
Docker Hub: Past, Present and Future by Ken Cochrane & BC Wong
 
July OpenNTF Webinar - HCL Presents Keep, a new API for Domino
July OpenNTF Webinar - HCL Presents Keep, a new API for DominoJuly OpenNTF Webinar - HCL Presents Keep, a new API for Domino
July OpenNTF Webinar - HCL Presents Keep, a new API for Domino
 
Docker Online Meetup #30: Docker Trusted Registry 1.4.1
Docker Online Meetup #30: Docker Trusted Registry 1.4.1Docker Online Meetup #30: Docker Trusted Registry 1.4.1
Docker Online Meetup #30: Docker Trusted Registry 1.4.1
 
Docker Overview - AWS Tech Connect - Seattle 10/28
Docker Overview - AWS Tech Connect - Seattle 10/28Docker Overview - AWS Tech Connect - Seattle 10/28
Docker Overview - AWS Tech Connect - Seattle 10/28
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
The Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With PuppetThe Art and Zen of Managing Nagios With Puppet
The Art and Zen of Managing Nagios With Puppet
 
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
 
Informix on Docker Hub
Informix on Docker HubInformix on Docker Hub
Informix on Docker Hub
 
Using Docker in production: Get started today!
Using Docker in production: Get started today!Using Docker in production: Get started today!
Using Docker in production: Get started today!
 
Introduction to Docker | Docker and Kubernetes Training
Introduction to Docker | Docker and Kubernetes TrainingIntroduction to Docker | Docker and Kubernetes Training
Introduction to Docker | Docker and Kubernetes Training
 
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
 
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ....docker : How to deploy Digital Experience in a container, drinking a cup of ...
.docker : How to deploy Digital Experience in a container, drinking a cup of ...
 
IIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and DockerIIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and Docker
 
DockerCon EU 2015 Barcelona
DockerCon EU 2015 BarcelonaDockerCon EU 2015 Barcelona
DockerCon EU 2015 Barcelona
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container world
 
Docker Hub Breakout Session at DockerCon by Ken Cochrane
Docker Hub Breakout Session at DockerCon by Ken CochraneDocker Hub Breakout Session at DockerCon by Ken Cochrane
Docker Hub Breakout Session at DockerCon by Ken Cochrane
 

Similar to Packaging a Python application after you messed up - Roman Prykhodchenko

Upgrading CentOS on the Facebook fleet
Upgrading CentOS on the Facebook fleetUpgrading CentOS on the Facebook fleet
Upgrading CentOS on the Facebook fleet
Davide Cavalca
 
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
Yoshitake Kobayashi
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
php-user-group-minsk
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Max Romanovsky
 
CentOS Stream at Facebook
CentOS Stream at FacebookCentOS Stream at Facebook
CentOS Stream at Facebook
Davide Cavalca
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
Geeta Vinnakota
 
Unicon Nov 2014 IAM Briefing
Unicon Nov 2014 IAM BriefingUnicon Nov 2014 IAM Briefing
Unicon Nov 2014 IAM Briefing
John Gasper
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013dotCloud
 
Lightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeLightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeDocker, Inc.
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
Chris Tankersley
 
Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifeidotCloud
 
Alibaba Cloud Conference 2016 - Docker Open Source
Alibaba Cloud Conference   2016 - Docker Open Source Alibaba Cloud Conference   2016 - Docker Open Source
Alibaba Cloud Conference 2016 - Docker Open Source
John Willis
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
Travis Oliphant
 
DockerCon Recap - Online Meetup by Ben Firshman
DockerCon Recap - Online Meetup by Ben FirshmanDockerCon Recap - Online Meetup by Ben Firshman
DockerCon Recap - Online Meetup by Ben FirshmanDocker, Inc.
 
Bring Your Own Container: Using Docker Images In Production
Bring Your Own Container: Using Docker Images In ProductionBring Your Own Container: Using Docker Images In Production
Bring Your Own Container: Using Docker Images In Production
Databricks
 
Modern .NET Ecosystem
Modern .NET EcosystemModern .NET Ecosystem
Modern .NET Ecosystem
Andrei Marukovich
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013dotCloud
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
Betclic Everest Group Tech Team
 
Moby KubeCon 2017
Moby KubeCon 2017Moby KubeCon 2017
Moby KubeCon 2017
Patrick Chanezon
 
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfO365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
NCCOMMS
 

Similar to Packaging a Python application after you messed up - Roman Prykhodchenko (20)

Upgrading CentOS on the Facebook fleet
Upgrading CentOS on the Facebook fleetUpgrading CentOS on the Facebook fleet
Upgrading CentOS on the Facebook fleet
 
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
 
CentOS Stream at Facebook
CentOS Stream at FacebookCentOS Stream at Facebook
CentOS Stream at Facebook
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Unicon Nov 2014 IAM Briefing
Unicon Nov 2014 IAM BriefingUnicon Nov 2014 IAM Briefing
Unicon Nov 2014 IAM Briefing
 
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
Write Once and REALLY Run Anywhere | OpenStack Summit HK 2013
 
Lightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeLightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in Practice
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
 
Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifei
 
Alibaba Cloud Conference 2016 - Docker Open Source
Alibaba Cloud Conference   2016 - Docker Open Source Alibaba Cloud Conference   2016 - Docker Open Source
Alibaba Cloud Conference 2016 - Docker Open Source
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
 
DockerCon Recap - Online Meetup by Ben Firshman
DockerCon Recap - Online Meetup by Ben FirshmanDockerCon Recap - Online Meetup by Ben Firshman
DockerCon Recap - Online Meetup by Ben Firshman
 
Bring Your Own Container: Using Docker Images In Production
Bring Your Own Container: Using Docker Images In ProductionBring Your Own Container: Using Docker Images In Production
Bring Your Own Container: Using Docker Images In Production
 
Modern .NET Ecosystem
Modern .NET EcosystemModern .NET Ecosystem
Modern .NET Ecosystem
 
Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Moby KubeCon 2017
Moby KubeCon 2017Moby KubeCon 2017
Moby KubeCon 2017
 
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfO365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 

Packaging a Python application after you messed up - Roman Prykhodchenko

  • 1. Packaging a Python application after you messed up Roman Prykhodchenko, Allegro @romcheg me@romcheg.me November 2019, Warsaw www.devopsdays.pl
  • 2. DevOpsDays Warsaw 2019 • Maintained and used in house • Heavily modified django-admin • Python + HTML + JS • Open-source + private extensions • In house: Ubuntu + Docker image • In community: mostly Ubuntu + deb package but.... DCIM system: Ralph 2
  • 3. DevOpsDays Warsaw 2019 Problem • Community builds are often broken • Troubleshooting takes more time than we have • No motivation to support the community 3
  • 4. DevOpsDays Warsaw 2019 Reasons • Two separate delivery pipelines • TravisCI: Debian package built and published once a week • Bamboo: Docker image with private extensions available on demand • Different artefacts in community and local packages • Supporting the community is not the team's #1 priority 4
  • 5. DevOpsDays Warsaw 2019 Solution: Improve the delivery pipeline by re-thinking packaging. 5
  • 6. DevOpsDays Warsaw 2019 • ... a file with an .rpm or .deb in the end • ... a python wheel • ... a tarball with a source code and a Makefile • ... a container image?! 0_o Package is... 6
  • 7. DevOpsDays Warsaw 2019 Package is a distributable set of idempotent alternations bringing desired artefacts and state changes to a target system. 7
  • 8. DevOpsDays Warsaw 2019 Containerisation is a form of packaging – the rules apply. 8
  • 9. DevOpsDays Warsaw 2019 Delivery pipeline Source code 0 1 0 1 0 1 1 1 0 Build toolchain Artefacts Build dependencies Runtime dependencies Packaging toolchain Package 9
  • 10. DevOpsDays Warsaw 2019 Target platforms MutableImmutable • Artefacts • Configuration • Dependencies • Artefacts • Configuration • List of dependencies Runtime depencencies Fetch 10
  • 11. DevOpsDays Warsaw 2019 Target platforms Runtime dependencies are available in vendor repositories. Runtime dependencies are shipped within the package. 11
  • 12. DevOpsDays Warsaw 2019 • Supporting the community was not #1 priority 12
  • 13. DevOpsDays Warsaw 2019 Solution: 1. Create a single pipeline for the community and ourselves 2. Pack the same artefacts into different packages 13
  • 15. DevOpsDays Warsaw 2019 0 1 1 0 0 1 1 0 15
  • 16. DevOpsDays Warsaw 2019 • cPython 3.4+ • Database drivers + other shared libraries • Required python libraries • ... • Django-* Runtime dependencies 16
  • 17. DevOpsDays Warsaw 2019 Deb package Artefacts: 1. Python code 2. Static files 3. Configuration Runtime dependencies: 1. python-3 2. mysql-common 3. ... 4. python3-mysql 5. python3-django 6. python3-* 17
  • 18. DevOpsDays Warsaw 2019 Never run pip install on a target system. 18
  • 19. DevOpsDays Warsaw 2019 • Copy dependencies to the source tree • Keeping wheels in the source tree • Package a virtual environment 0_o • No source-code changes required • Use standard management tools • Gradual migration to system packages Other options? 19
  • 20. DevOpsDays Warsaw 2019 • Create one • Install python stuff • Required packages • Source code • Fix the symlinks • Pack the virtualenv into the deb package Virtualenv 20
  • 21. DevOpsDays Warsaw 2019 dh_virtualenv does all of that for you! debian/control: 21
  • 22. DevOpsDays Warsaw 2019 dh_virtualenv does all of that for you! debian/rules: 22
  • 23. DevOpsDays Warsaw 2019 • Use all matching requirements from the vendor's repository • Use dh_virtualenv • Put the rest of the requirements along with the source code into the virtualenv • Gradually migrate the code to the libraries available in the vendor's repositories Deb package – summary 23
  • 24. DevOpsDays Warsaw 2019 Docker image – extra layer of complexity • Supporting different container orchestrators • Configuration without breaking immutability • Performing operations without entering running containers • Serving static files 24
  • 25. DevOpsDays Warsaw 2019 • Single entry point script • Avoid exposing the filesystem structure • Acts like a facade for all entry points • By default starts the service Startup and operations 25
  • 26. DevOpsDays Warsaw 2019 • Select few essential configuration options and define environment variables for each • The entry point script puts the values of those variables into configuration files • Those in need of supplying advanced configuration should mount the entire configuration as a volume Configuration 26
  • 27. DevOpsDays Warsaw 2019 • Build a separate image with static files • Use a lightweight image like nginx as a base • Users will route requests to one of the containers depending on the container orchestrator Static files 27
  • 28. DevOpsDays Warsaw 2019 • Custom entry point acting like a facade • Essential configuration options as environment variables • Advanced configuration is done by mounting configuration as a volume • Static files are available in a separate image • Publish both images at the same time Docker image – summary 28
  • 30. DevOpsDays Warsaw 2019 Support opinionated scenarios based on in-house usage. 30
  • 31. DevOpsDays Warsaw 2019 Improve things gradually. 31
  • 32. DevOpsDays Warsaw 2019 Be ready to say goodbye to corner-case users to make the vast majority happy. 32
  • 33. DevOpsDays Warsaw 2019 Does not matter what decisions you make, unless they are irreversible. 33
  • 35. Roman Prykhodchenko, Allegro @romcheg me@romcheg.me I'm waiting for your feedback! You can rate speakers and lectures using our official conference app

Editor's Notes

  1. Let me just brief you quickly with the background -- I am an engineer in a team supporting certain part of the technical platform at our company and our team had a problem!
  2. Running our services requires an extensive infrastructure built with a few thousands of assets. In order to handle that we have created a DCIM Ralph with the main goal to be the software that fulfils our internal needs. At some point of time it was published under apache license just because... somehow it gained some popularity
  3. For the company Ralph is not a product therefore the team's focus must stay on the in-house needs, including maintenance of other systems. Open-sourcing this sort of software is debatable, yet here we are and there's no way back.
  4. distributable --
  5. That means all the constraints apply.
  6. Immutable -- you should supply runtime dependencies Mutable -- you may fetch dependencies from a trusted source
  7. Then we gave it another thought and realised the cornerstone of the mess is the last issue and as the matter of fact it's the only one from the list we cannot fix since it is a direct consequence of the business model of the company. Following the DevOps philosophy means taking responsibility for more then just the development, so we could not ignore that.
  8. The basic idea was that whatever is given to the community should be also used by us.
  9. That required to make several unpopular, yet necessary changes in the initial plan -- and the first of them was to sacrifice the idea of RPM builds. Moreover -- we had to select only one Debian-based distribution of GNU/Linux which is used in the vast majority of use cases.
  10. Django application often ends up being dependent on a ton of libraries from the Django ecosystem and the combination often works only when all requirements have very specific range of versions.
  11. External python libraries are available in canonical's repositories under certain names. Canonical maintains those packages and provides patches and security updates Yet those libraries have specific versions that won't match the requirements of the python code. There's a way to install python libraries -- pip install/easy_install -- installs from PyPi/other repos. With django that's a huge problem.
  12. Python package management is non deterministic -- requirements do not have strict versions, you never know what gets installed on the target system. Even if you freeze the dependency tree: Installing python packages may require build tools to compile extensions written in C. Random failures We have to bring those requirements inside the package.
  13. huge source tree, long installation, more c-libraries required, changes in the source code may be necessary to fix imports Complicated installation process, more steps to update requirements, cannot use standard python package management tools Seems funny, but... Good as a transitional stage
  14. Therefore it is necessary to add some sort of script to the pipeline that will do the following steps: Sounds like too much of a hustle for a transitional stage.
  15. When designing a container image, it is necessary to keep in mind that "docker run" is not how containers are often run on production. Container orchestrators like "Kubernetes" or even simple "docker-compose" require some work to be done before an image can be actually used. Docker isolates what's inside, yet it's often necessary to get under the hood, e.g. to configure the software or to perform different operations.
  16. Since static files are inside the container, serving them won't be as easy
  17. To summarise – when open-sourcing your software while the human-power is limited or when priorities do not put community to the 1st place follow these 3 strategies: Well done opinionated software is much better than weak one that provides many options.
  18. Trying to start with a "by the book" approach is likely to be too time consuming or too expensive.
  19. Be ready to receive tons of negative feedback or anger.