ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.68k stars 387 forks source link

Add support for building snaps #307

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi Steve,

Following up on what we briefly discussed, this is the PR for building a snap package of ponzu.

Build and test

You can use:

Build locally

I used Ubuntu 18.04 for this.

snap install snapcraft --classic --beta git clone https://github.com/igorljubuncic/ponzu.git cd ponzu git checkout add-snapcraft snapcraft

This command will generate a .snap file, something like ponzu_1.0_amd64.snap.

Install locally

snap install ponzu_1.0_amd64.snap --dangerous

The --dangerous flag is necessary because the app (snap) does not originate from the snap store just yet and is not digitally signed.

Run ponzu

snap run ponzu "options"

Register dev account

You can do this here: https://snapcraft.io/account.

Register ponzu name in the store

This can be done on the command line with snapcraft:

snapcraft login snapcraft register

Upload/push ponzu to the store

snapcraft push ponzu_1.0_amd64.snap --release edge

We use release channels to denote risk, as follows:

You can promote to different channels after testing and validation.

Install from store for (a second) test

snap install ponzu --edge

I think this covers it.

Once you land the PR, we can help you with the promotion of ponzu.

Feel free to ask any questions you may have.

Thanks!

nilslice commented 5 years ago

Hi @igorljubuncic -

Thank you for this, it's extremely helpful!

Ponzu has a dev dependency on the Go toolchain. Is there a way to ensure through the snap install that Go (above some defined version) is also installed? and if not, to install it along with Ponzu?

ghost commented 5 years ago

Yes, absolutely. You can define that with the build-packages keyword - so if you need a package named foobar3-dev, you can add it. For instance, the snapcraft.yaml I uploaded has:

build-packages:
  - build-essential

You could have something like:

build-packages:
  - build-essential
  - foobar3-dev

Similarly, for runtime assets, you can use the stage-packages keyword.

I hope this answers your question.

olliephillips commented 5 years ago

Hello @igorljubuncic, may I ask, in the context of a snap, can a package dependency be another Snap. I see there's Go already in the snapcraft store. That would seem to be a simple way to ensure Go is available?

ghost commented 5 years ago

Hi Ollie, do you need this resubmitted to the dev branch?

olliephillips commented 5 years ago

@igorljubuncic if you could even though it's not a change that impacts the Ponzu code base that'd be great.

But is the file complete from your perspective? I don't think it factors in the golang build dependency discussed above, so would fail for some users?

Could that be added so you have a complete snap.yml?

ghost commented 5 years ago

Hey Ollie,

There are several options available:

https://forum.snapcraft.io/t/stage-snaps/11001

I believe this will fully satisfy your requirements.

I'm going to file a new PR - with the same text above, and reference this one.

olliephillips commented 5 years ago

Closing as PR superseded by #313