Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Deploy to ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
goga-m committed Nov 26, 2017
1 parent f490fa8 commit f927f15
Show file tree
Hide file tree
Showing 8 changed files with 889 additions and 515 deletions.
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SHELL=/bin/bash
DOMAIN="benchmark.js.ipfs.io"

IPFSLOCAL="http://localhost:8080/ipfs/"
IPFSGATEWAY="https://ipfs.io/ipfs/"
NPM=npm
NPMBIN=./node_modules/.bin
OUTPUTDIR=dist
PREPEND=@

build:
@echo "Installing npm modules..."
$(PREPEND)npm install && \
echo "" && \
echo "Installed npm modules"
$(PREPEND)npm run build
@echo "All files built to ./$(OUTPUTDIR)";
@echo "";
@echo "Next steps (make sure you have ipfs deamon running):";
@echo "- make deploy";
@echo "";

help:
@echo 'Makefile for ipfs benchmarks'
@echo ' '
@echo 'Usage: '
@echo ' make Build the optimised site to ./$(OUTPUTDIR) '
@echo ' make deploy Add the website to your local IPFS node '
@echo ' make publish-to-domain Update $(DOMAIN) DNS record to the ipfs hash from the last deploy '
@echo ' '

deploy:
$(PREPEND)ipfs add -r -q $(OUTPUTDIR) | tail -n1 >versions/current ; \
cat versions/current >>versions/history ; \
export hash=`cat versions/current`; \
echo ""; \
echo "published website:"; \
echo "- $(IPFSLOCAL)$$hash"; \
echo "- $(IPFSGATEWAY)$$hash"; \
echo ""; \
echo "next steps:"; \
echo "- ipfs pin add -r /ipfs/$$hash"; \
echo "- make publish-to-domain"; \

publish-to-domain: versions/current
DNSIMPLE_TOKEN="$(shell if [ -f auth.token ]; then cat auth.token; else cat $HOME/.protocol/dnsimple.ipfs.io.token; fi)" \
./dnslink.sh $(DOMAIN) $(shell cat versions/current)

.PHONY: build help install deploy publish-to-domain clean
72 changes: 66 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# js-ipfs-browser-benchmarks
# [Benchmaks for js-ipfs](ipfs.io)

> Benchmarking tests for js-ipfs streaming files in browser
> Benchmarking interface for js-ipfs https://github.com/ipfs/js-ipfs
## Install

> For a quick preview, check the online [demo](https://goga-m.github.io/js-ipfs-browser-performance/)
## Build Setup
```sh
> git clone https://github.com/ipfs/benchmark.js.ipfs.io.git
```

## Custom Build Setup (optional)
To develop & build locally run :
Note: no need to run these commands if you are using the make commands below to deploy to IPFS)
``` bash
# install dependencies
npm install
Expand All @@ -21,4 +25,60 @@ npm run build
npm run build --report
```

For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

## Deploy to IPFS

To deploy the site Benchmark.js.ipfs.io, run :

```sh
# Install all the necessary dependencies and build out the optimized site where you can check it locally
> make

# Add the site to your local ipfs, you can check it via /ipfs/<hash>
> make deploy

# Save your dnsimple api token as auth.token
> cat "<api token here>" > auth.token

# Update the dns record for ipfs.io to point to the new ipfs hash.
> make publish-to-domain
```

The following commands are available:

### `make`

Build the optimised site to the `./dist` dir

### `make deploy`

Build the site in the `dist` dir and add to `ipfs` _(requires`ipfs` on your `PATH`)_

### `make publish-to-domain` :rocket:

Update the DNS record for `ipfs.io`. _(requires an `auto.token` file to be saved in the project root.)_

If you'd like to update the dnslink TXT record for another domain, pass `DOMAIN=<your domain here>` like so:

```sh
> make publish-to-domain DOMAIN=tableflip.io
```

---

See the `Makefile` for the full list or run `make help` in the project root.

## Dependencies
- `Node.js` and `npm` for build tools
- `ipfs` to deploy changes
- `jq`, `curl` and an `auth.token` file in the project root containing your dnsimple api token to update the dns

All other dependencies are pulled from `npm` and the Makefile will run `npm install` for you because it's nice like that.

## Contribute

Please do! Check out [the issues](https://github.com/ipfs/benchmark.js.ipfs.io/issues), or open a PR!

Check out our [notes on contributing ](https://github.com/ipfs/js-ipfs#contribute) for more information on how we work, and about contributing in general. Please be aware that all interactions related to IPFS are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
assetsPublicPath: './',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
Expand Down
53 changes: 53 additions & 0 deletions dnslink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

#
# Usage:
# DNSIMPLE_TOKEN=<token> ./dnslink.sh <domain> <hash>
#
# Example:
# DNSIMPLE_TOKEN=trustno1 ./dnslink.sh website.protocol.ai Qmfoobar
#
# Dependencies:
# - bash
# - curl
# - jq
#
# From:
# https://raw.githubusercontent.com/ipfs/infrastructure/master/scripts/dnslink.sh
#

set -e

ZONE="$1"
HASH="$2"

([ ! -z "$DNSIMPLE_TOKEN" ] && [ ! -z "$ZONE" ] && [ ! -z "$HASH" ]) \
|| (echo "Usage: DNSIMPLE_TOKEN=<token> ./dnslink.sh <domain> <hash>" && exit 1)

RECORD_NAME="_dnslink"
RECORD_TTL=120

record_id=$(
curl -v -s "https://api.dnsimple.com/v1/domains/$ZONE/records?name=$RECORD_NAME&type=TXT" \
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \
-H "Accept: application/json" \
| jq -r '.[].record.id'
)

if [ -z "$record_id" ]; then
curl -v -s -X POST "https://api.dnsimple.com/v1/domains/$ZONE/records" \
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d "{\"record\":{ \"name\":\"$RECORD_NAME\", \"record_type\":\"TXT\", \"content\":\"dnslink=/ipfs/$HASH\", \"ttl\":\"$RECORD_TTL\" }}" \
| jq -r '.record' \
&& printf "\\nIt looks like we're good: https://ipfs.io/ipns/$ZONE\\n"
else
curl -v -s -X PUT "https://api.dnsimple.com/v1/domains/$ZONE/records/$record_id" \
-H "X-DNSimple-Domain-Token: $DNSIMPLE_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d "{\"record\":{ \"content\":\"dnslink=/ipfs/$HASH\", \"name\":\"$RECORD_NAME\", \"ttl\":\"$RECORD_TTL\" }}" \
| jq -r '.record' \
&& printf "\\nIt looks like we're good: https://ipfs.io/ipns/$ZONE\\n"
fi
Loading

0 comments on commit f927f15

Please sign in to comment.