Including Postgresql in a Snap App

James Jesudason james.jesudason at canonical.com
Wed Jul 13 08:23:01 UTC 2016


On 13 July 2016 at 06:52, Steven Holms <superlinkx at gmail.com> wrote:

> Has anyone had success in setting up a postgresql server within a snap?
> I've been reading over the docs, and figured I'd try adding postgresql as a
> stage-package, but now I'm not sure how to get it up and running within my
> snap. I think I'm on the right track, I just don't know how to configure
> the "app" portion of it so that the daemon will run.
>
> My app is pretty simple. It's a go server that needs access to postgresql
> for it's backend. I know I can communicate with an external postgresql
> database, but was hoping to get it all into one package.
>
> Any help is appreciated.
>
>
I've done something like this for a project that I'm working on, though the
architecture is slightly different to what you are suggesting. I have a Go
web service that uses the network and network-bind plugs and then I'm using
the postgresql snap from the store. So, I use two separate snaps and then
use a command on my web service snap to set the config file (so it knows
how to connect to postgresql). After that, a simple restart of the web
service snap and everything is connected.

Go web service: https://github.com/ubuntu-core/identity-vault
Web service snap files: https://github.com/ubuntu-core/serial-vault-snap
(these files will soon be moved to the web service source repo)

As a bonus, there is also a juju 2.0 charm that deploys the web service:
https://github.com/ubuntu-core/serial-vault-charm

Even if you are not going to use the charm for deployment, it is helpful as
it walks you through the commands that you need to get config file set up
and pushed to the snap. Kudos to Evan Dandrea as I just copied his approach
for config from the Jenkins Snap [1]. With this approach, it works just as
well if the snaps are on the same machine or on separate juju units.

James

[1] https://github.com/evandandrea/jenkins-snap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/snapcraft/attachments/20160713/c7a128a7/attachment.html>


More information about the Snapcraft mailing list