Nov 12, 2017

Microservices: Ubuntu Core: Building your own snap application

After the installation of ubuntu core and running caddy webserver from a repository  i was wondering how to build my own snap package.

The tutorial shows how to build GNU Hello into a snap packages:
and this tutorial works fine.
But this does not really help, if you have a command, which you can not build with autotools or ant or ....
A complete list can be found here.

So my plan:
  • create a bash script "myapp.sh"
  • try to build a snap, which contains this file
My first step was to create a directory "myapp" and create a "snapcraft.yaml" file:
name: myapp
version: "2.13"
summary: My first snap
description: My first snap app
confinement: strict

apps:
          myapp:
                      command: myapp.sh

parts:
          myapp:
                      plugin: nil
 Inside the myapp directory i created "prime/bin/myapp.sh" and "stage/myapp.sh". For both i changed the execution bits:
(With only u+x i got "-bash: ./myapp.sh: Permission denied")

chmod uga+x
Then i ran
$ snapcraft
"grade" property not specified: defaulting to "stable"
Skipping pull myapp (already ran)
Skipping build myapp (already ran)
Skipping stage myapp (already ran)
Skipping prime myapp (already ran)
Snapping 'myapp' |                                                                                                                                            
Snapped myapp_2.13_amd64.snap
This file i transferred to my ubuntu core and installed it with:
$ snap install --dangerous  myapp_2.13_amd64.snap
myapp 2.13 installed
And:
d-schroff@localhost:~$ myapp
This is myapp.



Other posts around this topic: Snapcraft / Snap on ubuntu core

  • Installing Ubuntu Core on Virtualbox
  • Creating a snap containing only a shell script
  • Running a webserver (caddy) with snap
  • No comments:

    Post a Comment