ParalelnaPolisKE / paralelnapoliskosice.sk

▵ Website of Paralelná Polis Košice
https://www.paralelnapoliskosice.sk
The Unlicense
7 stars 6 forks source link

Automated upload of latest version of website to IPFS + pin #78

Open michaltakac opened 5 years ago

michaltakac commented 5 years ago

Maybe we can use some deployment webhook from Netlify. Deployed -> trigger script or something. We can use https://github.com/ipfs/js-ipfs. Idk about pinning yet.

crazko commented 5 years ago

Can you please elaborate more on what'd be added to IPFS? The whole site? Where it would be "hosted"? And what is pinning, I'm a bit newbie in this field.

michaltakac commented 5 years ago

Sure.

Frist of all, anyone who wants to, can run an IPFS node - you need to have it running when adding files to the IPFS network and by running more IPFS nodes, this way we can make sure that the content we upload will stay on the IPFS network. To persist the data, one or more nodes need to "pin" it to the network, actually telling the IPFS network to keep particular content in the network cached on multiple nodes, preventing IPFS's garbage collection that run every 24 hours to delete it from the network cache.

Now, we can add whole site to the IPFS by first starting IPFS daemon and doing ipfs add -r root-dir - this command 1 will take content of every file in that root-dir, every subfolder and every nested files there also, slice it into 256kb chunks, hash the content of particular chunk and create Merkle DAG 2 with "root hash" representing root-dir.

Our root hash will look like this: QmNhFJjGcMPqpuYfxL62VVB9528NXqDNMFXiqN5bgFYiZ1 (but different alphanumeric characters). If you then accessed it at the local IPFS gateway (that your node provides) - http://localhost:8080/ipfs/QmNhFJjGcMPqpuYfxL62VVB9528NXqDNMFXiqN5bgFYiZ1/ - you'll see the folder with static files in it, or, if there was index.html inside the folder, you'll get website rendered. Wohoo! It's hosted on IPFS network! Well... for 24 hours at least. Then this content will get garbage-collected and not accessible anymore from https://ipfs.io/ipfs/Qm...

So, you'll need to "pin" it from different node - to actually cache the content on it and tell the network to ignore the root hash when garbage collection happens. It's good to re-pin it once in a while, like once in few days or so.

More info about pinning here: https://medium.com/ethereum-developers/how-to-host-your-ipfs-files-online-forever-f0c56b9b5398


michaltakac commented 5 years ago

This would make for a nice small IPFS workshop. Adding that to Trello.

crazko commented 5 years ago

OK, this one sure needs a workshop :)


recently I came upon Beaker browser and dat protocol which look very similar, probably even more suitable, at a first glance.

We could explore this as well.

crazko commented 5 years ago

I've removed good first issue label, it's meant to label easy tasks for newcomers ... and this one is probably not so easy 😆

michaltakac commented 5 years ago

It just looks like it is complex, but (at least I think) it should be easily doable with js-ipfs. But nvm, I'll work on this one when I'll find time.

michaltakac commented 5 years ago

Hmm, looks like links won't work out-of-box.

screen shot 2019-01-24 at 14 41 45
crazko commented 5 years ago

they are relative to the document root. This config might help https://www.gatsbyjs.org/docs/gatsby-config/#pathprefix but it has to be re-built especially for this case with correct prefix. I don't know if this is possible.