Examples for publishing webapps to IPFS from CI

Is there somebody publishing the static assets of a webapp to ipfs via CI (travis or similar)? I would like to pitch using IPFS within my employer actyx, and one of the first obvious applications would be deployment of static assets of apps.

The process would involve publishing the output using ipfs add -r and then updating an ipns entry pointing to the hash, but there are a few things that are unclear to me. Having a template would be very helpful.



1 Like

More than a few of us have slow name resolution times – to the point where it’s a problem, so this is one thing I would focus on first: whether or not you can reliably resolve ipns/ipfs-peer-id fast enough consistently. Sometimes our site is super fast, other times it’s slow as hell. Struggling to correct it by pinning to more nodes (not sure how to view/verify how many are running it).

[EDIT] That is my suspicion is that the peer-id -> CID resolution is the bottleneck at this time and not sure when that’s going to be worked on (per comments by Protocol employees about focus of Go engineers)

This is the command I’m talking about: https://ipfs.io/docs/commands/#ipfs-name-resolve


I have also seen slow or unresponsive behaviour of ipfs name publish. However, currently we plan to use this in a very small private ipfs network, where the performance should not be an issue. We did some tests, and ipns was reasonably fast.

So how would I do this? One option would be to download and setup an ipfs node with the private swarm key and bootstrap nodes from our ci just for the purpose of uploading a directory. But that seems a bit complex.

Another option would be to use the REST api on port 5001. But I could not find good documentation how to upload a directory, and also the API is kind of weird. E.g. as far as I have seen, you can pin something by doing a GET request, which is not how REST apis are supposed to work.

Just in case somebody is curious, here is what we ended up doing:

We have an AWS EC2 instance running an ipfs node. This is connected to our private swarm, but the same approach would also work if we were connected to the global ipfs swarm. On this node we have configured various keys for assets and applications, and the various stages (dev, qa, release).

We have configured our travis-ci.com build with a ssh key that is allowed to ssh into the ipfs node.

On the node, we have a script ipfs-publish.sh that accepts a piped tar.gz file and publishes it to one of the keys in the keystore of the node running on the ec2 instance.

To push to that node, assuming the public key part of the key configured in travis in the authorized_keys of the ipfs node, you just need to execute

tar -cjvf - -C dirname . | ssh ipfs.company.net ipfs-publish.sh keyname --

from the .travis.yml of the build.

But we also have a script ipfs-publish-remote.sh that simplifies this and that can be called from the deploy script.

The only thing left is to add the target host to the known hosts, which can be done in the .travis.yml:

  - ipfs.company.net
1 Like