getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.62k stars 450 forks source link

Nice idea from Pelican #701

Closed ralsina closed 11 years ago

ralsina commented 11 years ago

http://blog.getpelican.com/using-pelican-with-heroku.html

Someone who actually knows about Heroku should steal this :-)

damianavila commented 11 years ago

I will investigate this link... From my little experience with Heroku, you can not save files there, so... you need to develop an app to render all you html content and show it when is requested...

Kwpolska commented 11 years ago

You cannot save files, but you can store stuff in a postgresql database.

But with that, you are limited to 10k files, for free. It’s cheaper to pony up a few bucks for an actual server, like nfsn or go with free hosting.

Kwpolska commented 11 years ago

Actually, reading through the source code, they seem to cheat. This thing does the following:

  1. download a prebuilt copy of Python
  2. install pip and pelican
  3. render with pelican
  4. COMPILE nginx
  5. Include the compiled site and nginx as part of the upload to heroku.
ralsina commented 11 years ago

well, we could do a similar thing with a much smaller server...

Kwpolska commented 11 years ago

Actually, nginx is tiny and takes 40 seconds on so-so hardware to build (I don’t know where the Pelican buildpack is executed, whether it is localhost or heroku servers).

PKGEXT='.pkg.tar' makepkg -d  40.88s user 3.11s system 183% cpu 24.023 total

And that includes some small overhead from makepkg. An alternative is nikola serve (which can be slow, and is generally not meant for high traffic) or magic implemented with Tornado (which is a -full dependency of ours through livereload; but not meant for serving static files).

And that very PKGBUILD includes some additional modules and options we could remove to speed it up further.

Kwpolska commented 11 years ago

It’s actually executed on the Heroku infrastructure. Which means it will likely be even faster than what I presented.

We’ll probably steal some code from that Pelican thing. Come to think of it, all we need to do is change two lines from the bin/compile file and have a proper conf/requirements.txt (and replace pelican with nikola everywhere). (go contact a lawyer or the guys behind Pelican if this is okay to do without breaking the license and/or copyright laws.)

damianavila commented 11 years ago

(go contact a lawyer or the guys behind Pelican if this is okay to do without breaking the license and/or copyright laws.)

Thay have a permisive license in that repository... so I don't see any problems to use it...

ralsina commented 11 years ago

Indeed that's MIT and we can use it. we could add a static binary for an MIT webserver and avoid the C building.

Kwpolska commented 11 years ago

or a MIT-compatible one. nginx is actually 2-clause BSD, which is differently-worded-MIT, pretty much.

(again, IANAL)

Kwpolska commented 11 years ago

Now that I’ve had quite a bit of experience with Heroku, this goes on my to-do list, right after the nikola-users site, which is nearing completion.

damianavila commented 11 years ago

Now that I’ve had quite a bit of experience with Heroku, this goes on my to-do list, right after the nikola-users site, which is nearing completion.

Great!

Kwpolska commented 11 years ago

Done!

I actually did not use 99% of the broken Pelican code. I used the Python buildpack as my base instead.

The caveat? We’re running nikola serve.

The buildpack: https://github.com/getnikola/heroku-buildpack-nikola

A compiled site: http://warm-inlet-8157.herokuapp.com/

Kwpolska commented 11 years ago

@ralsina, @damianavila: ping

ralsina commented 11 years ago

This is pretty awesome!