Migrating from GitHub to IPFS Deployments

... 2022-9-24 大约 2 分钟

# Migrating from GitHub to IPFS Deployments

In order to make deploying projects easier on the Managed Service, we are deprecating GitHub deployments in favour of IPFS.

Using IPFS provides a better experience for developers in a few ways:

  • Unlike with GitHub deployments, projects are built locally on your machine. This means that you can have full control over the environment. Resolving any issues with version compatibility such as node.js version or other dependencies is much faster and easier.
  • You can share your projects CID and ensure that everyone will be able to run the same project with the same results.
  • It’s decentralised, so that you don’t have to rely on a centralised party like GitHub to store your code.
  • And on top of this, you can deploy the same project to the SubQuery Network!

# How to migrate your poject to IPFS

  1. Update your project's dependencies.

    1. Update @subql/cli to the latest version: you can do this by running yarn add -D @subql/cli@latest or npm i -dev @subql/cli@latest
    2. We also recommend updating other dependencies at this time
    3. Pay attention to this issue: 926 (opens new window)
  2. package.json: Update the build command to subql build. It should look like this (opens new window).

  3. src/index.ts: If updating from @polkadot/api v6 (or earlier) add please update your src/index.ts to include this line (opens new window).

  4. project.yaml:

    1. Make sure your project is using manifest version 1.0.0. You can check this by looking at the specVersion field in project.yaml. If it is below 1.0.0, then run subql migrate and follow the migration steps to upgrade.

    2. Check that the datasources: mapping: file: references your code entrypoint correctly, usually this is ./dist/index.js

    3. If you're using a datasource processor (any processor: in the project.yaml) we need to ensure that it gets bundled during build and publish. To do so please update to the latest version of the package that now includes a bundled version. You can do this by adding exports to your package.json.

    ...
    "exports": {
      "processorName": "./node_modules/path/to/processor.js"
      // "frontierEvm": "./node_modules/@subql/frontier-evm-processor/dist/index.js"
      // "acalaEvm": "./node_modules/@subql/acala-evm-processor/dist/index.js",
      // "ethermintEVM": "./node_modules/@subql/ethermint-evm-processor/dist/index.js"
      // "chaintypes": "./src/chaintypes.ts" // chain types if required
    }
    
    1
    2
    3
    4
    5
    6
    7
    8

    We need to update the reference to the bundle in your project.yaml. To do this you can update any processor file paths to file: ./node_modules/@subql/<processor-name>/dist/bundle.js and replace <processor-name> with the processor you are using. If you are using @subql/datasource-processors this package is now deprecated, you can find the relevant replacement from the new datasource-processors repository (opens new window).

    1. If your project uses js/ts based custom Substrate Chain Types you will need to repeat the steps above but with the reference to your chain types.
  5. docker-compose.yaml: Update it to the latest docker compose version (opens new window) and add this directory (opens new window) to your repo. To test it we recommend running your project locally.

Please now rebuild and run your project locally to test these changes before proceeding using `yarn`, `yarn codegen`, `yarn build`, and then `yarn start:docker`. :::

# Test deploying your project to IPFS

Your project should now be ready to deploy via IPFS to SubQuery Managed Service or the SubQuery network. You can follow the guide here to deploy to IPFS and then publish to the Managed Service.

上次编辑于: 2022年9月24日 05:55