SlideShare a Scribd company logo
Snaps: from Zero to Hero
Dal pacchetto, all’immagine
Marco Trevisan
marco@ubuntu.com
CC BY-SA 3.0
classic
kernel
snappy
os
appapp
kernel config
os writable files
app writable
area
app writable
areaany package can
write to any file
read-only
snaps
writable
spaces
per snap
filesystem
versioned root writable area
(for services)
$SNAP_DATA
common root writable area
(for services)
$SNAP_COMMON
versioned user writable area
$SNAP_USER_DATA
/tmp (per service and
app)/tmp (per service and
app)
/tmp
(per service and app
process)
snap code & assets
(squashfs, RO bind-mounted in /snap/<snap_name>/<version>)
$SNAP
Service
common user writable area
$SNAP_USER_COMMON
Service CLI GUI
versioned root writable area
(for services)
$SNAP_DATA
common root writable area
(for services)
$SNAP_COMMON
versioned user writable area
$SNAP_USER_DATA
/tmp (per service and
app)/tmp (per service and
app)
/tmp
(per service and app
process)
~
/dev/<device>
/sys
/
(from
core snap)
/var/lib/snapd/hostfs
(/ from host)
snap code & assets
(squashfs, RO bind-mounted in /snap/<snap_name>/<version>)
$SNAP
Service
common user writable area
$SNAP_USER_COMMON
Service CLI GUI
Interazione tra snap
app snapapp snap
app writable
area
app writable
area
Le app sono confinate ed isolate
app snap
app writable
area
app snap
app writable
area
Ubuntu Core: un sistema all-snaps!
Ed un sistema moderno per creare distribuzioni
Kernel snap
Core snap
Gadget snap
App snap
App snap
App snap
Content interface snap
● Integrità assicurata da un sistema in sola lettura squashfs
● Non serve riflashare tutto quando cambia un componente
alla prova di snapd
Minimum system requirements
Processor Architecture
x86 or ARMv7+ (Cortex-A7 single core)
Memory
256MB
Flash Storage
512MB storage
Available Connectivity types
WiFi, Ethernet, USB, BT4.0 BLE, ..
# Prerequisito: installa snapd nel sistema
# O usa un immagine per KVM di Ubuntu-core
# http://snapcraft.io
# Installa ed esegui il tuo primo snap
$ snap find hello
$ sudo snap install hello
$ hello
$ snap list
# Snap può fornire servizi e diversi binari
$ hello
$ hello.universe
# Aggiorna gli snap nel sistema (automatico)
$ sudo snap refresh
# Passa alla versione di “hello” di un altro
# canale
$ sudo snap refresh hello --beta
$ hello
# Rimuove uno snap
$ sudo snap remove hello
# Uno snap più complesso!
$ sudo snap install face-detection-demo --devmode
--beta
# Apri http://localhost:8080 (service).
# Attiva la webcam via web o da:
$ face-detection-demo --enable-camera
# Il comando comunica (via Unix socket)
# col servizio, che è collegato alla webcam
# ed in ascolto sulla rete.
# Utilizza le altre opzioni, disponibili anche
# nell’interfaccia web
# Aggiorna all’ultima versione dell’app!
$ sudo snap refresh face-detection-demo --devmode --edge
# L’interfaccia web non funziona più,
# ed i dati son stati eliminati!
# facciamo il revert per recuperare servizio (e dati!):
$ sudo snap revert face-detection-demo --devmode
# La versione è blacklisted, non viene riscaricata
$ sudo snap refresh face-detection-demo --devmode --edge
$ sudo snap remove face-detection-demo
Build your first snap
Build snaps on classic, deploy on Ubuntu Core
https://tutorials.ubuntu.com/
create-first-snap
build-a-nodejs-service
# Creating this first (non trivial) snap!
# Ensure you have snapcraft installed
$ sudo apt install snapcraft
# Clone our source code
$ git clone
https://github.com/ubuntu/face-detection-demo
--branch vanilla
# Hint: snapcraft.yaml is available at
http://bit.ly/2d9UOKH
# Creazione metadata
$ cd face-detection-demo
$ snapcraft init
# Apri e modifica lo snapcraft.yaml:
name: face-detection-demo
version: ‘1.0’
summary: Demo for Face Detection statistics
description: |
This demo shows face detection statistics
with fun heads.
grade: devel
confinement: devmode
# Adding golang part
parts:
face-detection-backend:
source: .
plugin: go
go-importpath: github.com/ubuntu/face-detection-demo
build-packages:
- build-essential
- libopencv-dev
# Shipping backend assets
parts:
face-detection-backend:
[…]
assets-backend:
source: .
plugin: dump
snap: [images, frontfacedetection.xml]
# And finally, the website part!
parts:
face-detection-backend:
[…]
assets-backend:
[…]
website:
source: https://github.com/ubuntu/face-detection-web.git
plugin: bower
organize:
‘*’: ‘www/’
# First build and install
$ snapcraft
$ sudo snap install *.snap --devmode
# No http://localhost:8080 service or
face-detection-demo CLI!
-> We need to expose them explicitly
# Exposing a command and a service:
apps:
tool:
command: face-detection-cli
service:
command: face-detection-service
daemon: simple
restart-condition: always
# Rebuild, reinstall and profit!
$ snapcraft
$ sudo snap install *.snap --devmode
$ face-detection-demo.tool --help
# Simplifying command name:
apps:
face-detection-demo:
command: face-detection-cli
service:
[…]
# Rebuild, reinstall and check the new command
name!
$ snapcraft
$ sudo snap install *.snap --devmode
$ face-detection-demo --help
# Head over to http://localhost:8080
snapcraft.io/
developer.ubuntu.com/en/snappy
github.com/snapcore/snapd
github.com/snapcore/snapcraft
sudo snap install snap-codelabs
# http://localhost:8123

More Related Content

PPTX
Ultimate Unix Meetup Presentation
PDF
The Symfony CLI
PDF
Create your own composer package
DOCX
Dockerfish-Tutorial
PPTX
Ansible - simple it automation
KEY
Usando o Cloud
PDF
Dependency management with Composer
ODP
Fabric Fast & Furious edition
Ultimate Unix Meetup Presentation
The Symfony CLI
Create your own composer package
Dockerfish-Tutorial
Ansible - simple it automation
Usando o Cloud
Dependency management with Composer
Fabric Fast & Furious edition

Similar to Workshop: snap from zero to hero (20)

PDF
May The Nodejs Be With You
PDF
Getting instantly up and running with Docker and Symfony
PDF
Ubuntu Core 技术详解
PDF
Setting Up a Cloud Server - Part 3 - Transcript.pdf
PDF
Composer for Busy Developers - php|tek13
PDF
Embedded Android
PDF
ERP System Implementation Kubernetes Cluster with Sticky Sessions
PPTX
A Fabric/Puppet Build/Deploy System
PDF
Command line for the beginner - Using the command line in developing for the...
PPTX
Introduction to docker
DOCX
Backtrack Manual Part4
PDF
Composer: putting dependencies on the score
PDF
Continuous Delivery: The Next Frontier
PDF
Command Line Applications with Ruby
PDF
Composer, putting dependencies on the score
PPT
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
PPT
Capistrano Overview
ODP
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
ODP
Snaps on open suse
PDF
DCEU 18: Dockerfile Best Practices
May The Nodejs Be With You
Getting instantly up and running with Docker and Symfony
Ubuntu Core 技术详解
Setting Up a Cloud Server - Part 3 - Transcript.pdf
Composer for Busy Developers - php|tek13
Embedded Android
ERP System Implementation Kubernetes Cluster with Sticky Sessions
A Fabric/Puppet Build/Deploy System
Command line for the beginner - Using the command line in developing for the...
Introduction to docker
Backtrack Manual Part4
Composer: putting dependencies on the score
Continuous Delivery: The Next Frontier
Command Line Applications with Ruby
Composer, putting dependencies on the score
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
Capistrano Overview
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
Snaps on open suse
DCEU 18: Dockerfile Best Practices
Ad

More from Marco Trevisan (9)

PDF
State of the GNOME - 2022 - Ubuntu Summit
PDF
Ubucon 19 - The making of ubuntu desktop for 20.04
PDF
Introduzione ad ubuntu core - Qt day 2017
PDF
Introduzione ad ubuntu core
PDF
Alla scoperta di Ubuntu Phone, lo smartphone Open Source
PDF
Unity: la shell di Ubuntu Phone
PDF
Introduzione ad Autopilot
PDF
Unity: la shell di ubuntu
PDF
Openmoko - La costruzione di un “Telefoninux”
State of the GNOME - 2022 - Ubuntu Summit
Ubucon 19 - The making of ubuntu desktop for 20.04
Introduzione ad ubuntu core - Qt day 2017
Introduzione ad ubuntu core
Alla scoperta di Ubuntu Phone, lo smartphone Open Source
Unity: la shell di Ubuntu Phone
Introduzione ad Autopilot
Unity: la shell di ubuntu
Openmoko - La costruzione di un “Telefoninux”
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Empathic Computing: Creating Shared Understanding
PDF
KodekX | Application Modernization Development
PDF
Modernizing your data center with Dell and AMD
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
A Presentation on Artificial Intelligence
PDF
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
20250228 LYD VKU AI Blended-Learning.pptx
cuic standard and advanced reporting.pdf
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
Empathic Computing: Creating Shared Understanding
KodekX | Application Modernization Development
Modernizing your data center with Dell and AMD
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
A Presentation on Artificial Intelligence
Spectral efficient network and resource selection model in 5G networks

Workshop: snap from zero to hero

  • 1. Snaps: from Zero to Hero Dal pacchetto, all’immagine Marco Trevisan marco@ubuntu.com CC BY-SA 3.0
  • 2. classic kernel snappy os appapp kernel config os writable files app writable area app writable areaany package can write to any file read-only snaps writable spaces per snap filesystem
  • 3. versioned root writable area (for services) $SNAP_DATA common root writable area (for services) $SNAP_COMMON versioned user writable area $SNAP_USER_DATA /tmp (per service and app)/tmp (per service and app) /tmp (per service and app process) snap code & assets (squashfs, RO bind-mounted in /snap/<snap_name>/<version>) $SNAP Service common user writable area $SNAP_USER_COMMON Service CLI GUI
  • 4. versioned root writable area (for services) $SNAP_DATA common root writable area (for services) $SNAP_COMMON versioned user writable area $SNAP_USER_DATA /tmp (per service and app)/tmp (per service and app) /tmp (per service and app process) ~ /dev/<device> /sys / (from core snap) /var/lib/snapd/hostfs (/ from host) snap code & assets (squashfs, RO bind-mounted in /snap/<snap_name>/<version>) $SNAP Service common user writable area $SNAP_USER_COMMON Service CLI GUI
  • 5. Interazione tra snap app snapapp snap app writable area app writable area Le app sono confinate ed isolate app snap app writable area app snap app writable area
  • 6. Ubuntu Core: un sistema all-snaps! Ed un sistema moderno per creare distribuzioni Kernel snap Core snap Gadget snap App snap App snap App snap Content interface snap ● Integrità assicurata da un sistema in sola lettura squashfs ● Non serve riflashare tutto quando cambia un componente
  • 8. Minimum system requirements Processor Architecture x86 or ARMv7+ (Cortex-A7 single core) Memory 256MB Flash Storage 512MB storage Available Connectivity types WiFi, Ethernet, USB, BT4.0 BLE, ..
  • 9. # Prerequisito: installa snapd nel sistema # O usa un immagine per KVM di Ubuntu-core # http://snapcraft.io # Installa ed esegui il tuo primo snap $ snap find hello $ sudo snap install hello $ hello $ snap list # Snap può fornire servizi e diversi binari $ hello $ hello.universe
  • 10. # Aggiorna gli snap nel sistema (automatico) $ sudo snap refresh # Passa alla versione di “hello” di un altro # canale $ sudo snap refresh hello --beta $ hello # Rimuove uno snap $ sudo snap remove hello
  • 11. # Uno snap più complesso! $ sudo snap install face-detection-demo --devmode --beta # Apri http://localhost:8080 (service). # Attiva la webcam via web o da: $ face-detection-demo --enable-camera # Il comando comunica (via Unix socket) # col servizio, che è collegato alla webcam # ed in ascolto sulla rete. # Utilizza le altre opzioni, disponibili anche # nell’interfaccia web
  • 12. # Aggiorna all’ultima versione dell’app! $ sudo snap refresh face-detection-demo --devmode --edge # L’interfaccia web non funziona più, # ed i dati son stati eliminati! # facciamo il revert per recuperare servizio (e dati!): $ sudo snap revert face-detection-demo --devmode # La versione è blacklisted, non viene riscaricata $ sudo snap refresh face-detection-demo --devmode --edge $ sudo snap remove face-detection-demo
  • 14. Build snaps on classic, deploy on Ubuntu Core
  • 16. # Creating this first (non trivial) snap! # Ensure you have snapcraft installed $ sudo apt install snapcraft # Clone our source code $ git clone https://github.com/ubuntu/face-detection-demo --branch vanilla # Hint: snapcraft.yaml is available at http://bit.ly/2d9UOKH
  • 17. # Creazione metadata $ cd face-detection-demo $ snapcraft init # Apri e modifica lo snapcraft.yaml: name: face-detection-demo version: ‘1.0’ summary: Demo for Face Detection statistics description: | This demo shows face detection statistics with fun heads. grade: devel confinement: devmode
  • 18. # Adding golang part parts: face-detection-backend: source: . plugin: go go-importpath: github.com/ubuntu/face-detection-demo build-packages: - build-essential - libopencv-dev
  • 19. # Shipping backend assets parts: face-detection-backend: […] assets-backend: source: . plugin: dump snap: [images, frontfacedetection.xml]
  • 20. # And finally, the website part! parts: face-detection-backend: […] assets-backend: […] website: source: https://github.com/ubuntu/face-detection-web.git plugin: bower organize: ‘*’: ‘www/’
  • 21. # First build and install $ snapcraft $ sudo snap install *.snap --devmode # No http://localhost:8080 service or face-detection-demo CLI! -> We need to expose them explicitly
  • 22. # Exposing a command and a service: apps: tool: command: face-detection-cli service: command: face-detection-service daemon: simple restart-condition: always # Rebuild, reinstall and profit! $ snapcraft $ sudo snap install *.snap --devmode $ face-detection-demo.tool --help
  • 23. # Simplifying command name: apps: face-detection-demo: command: face-detection-cli service: […] # Rebuild, reinstall and check the new command name! $ snapcraft $ sudo snap install *.snap --devmode $ face-detection-demo --help # Head over to http://localhost:8080