Publish to Managed Services
Publish to Managed Services
Benefits of hosting your project with SubQuery's Managed Service
The biggest dApps depend on SubQuery's enterprise level Managed Service. With 100's of millions of daily requests and hundreds of active projects, SubQuery's Managed Service provides industry leading hosting for our customers.
- We'll run your SubQuery projects for you in a high performance, scalable, and managed public service.
- This service is being provided to the community with a generous free tier! You can host your first two SubQuery projects for absolutely free!
- You can make your projects public so that they'll be listed in the SubQuery Explorer and anyone around the world can view them.
You can upgrade to take advantage of the following paid services:
- Production ready hosting for mission critical data with zero-downtime blue/green deployments
- Dedicated databases
- Multiple geo-redundant clusters and intelligent routing
- Advanced monitoring and analytics.
Publish your SubQuery project to IPFS
When deploying to SubQuery's Managed Service, you must first host your codebase in IPFS. Hosting a project in IPFS makes it available for everyone and reduces your reliance on centralised services like GitHub.
GitHub Deployment flows have being deprecated for IPFS
If your project is still being deployed via GitHub, read the migration guide for IPFS deployments here :::
요구 사항
@subql/cli
버전 0.21.0 이상.- Manifest
specVersion
1.0.0 and above. - Get your SUBQL_ACCESS_TOKEN ready.
- To make sure your deployment is successful, we strongly recommend that you build your project with the
subql build
command, and test it locally before publishing.
SUBQL_ACCESS_TOKEN 준비
- 1단계: SubQuery 프로젝트로 이동하여 로그인합니다.
- Step 2: Click on your profile at the top right of the navigation menu, then click on Refresh Token.
- 3단계: 생성된 토큰을 복사합니다.
- 4단계: 이 토큰을 사용하려면:
- 옵션 1: 환경 변수에 SUBQL_ACCESS_TOKEN을 추가합니다.
EXPORT SUBQL_ACCESS_TOKEN=<token>
(Windows) orexport SUBQL_ACCESS_TOKEN=<token>
(Mac/Linux) - 옵션 2: 곧 나올 예정입니다.
subql/cli
는 SUBQL_ACCESS_TOKEN을 로컬에 저장하는 것을 지원할 것입니다.
- 옵션 1: 환경 변수에 SUBQL_ACCESS_TOKEN을 추가합니다.
프로젝트를 게시하는 방법
Run the following command, which will read the project's default manifest project.yaml
for the required information.
// Publish it from your project's root directory
subql publish
// OR point to your project root
subql publish -f ~/my-project/
Alternatively, if your project has multiple manifest files, for example you support multiple networks but share the same mapping and business logic, and have a project structure as follows:
L projectRoot
L src/
L package.json
L polkadot.yaml (Manifest for Polkadot network)
L kusama.yaml (Manifest for Kusama network)
...
선택한 매니페스트 파일로 언제든지 프로젝트를 게시할 수 있습니다.
# This will publish project support indexing Polkadot network
subql publish -f ~/my-projectRoot/polkadot.yaml
게시 후
After successfully publishing the project, the logs below indicate that the project was created on the IPFS cluster and have returned its CID
(Content IDentifier). Please note down this CID
.
Building and packing code... done
Uploading SupQuery project to IPFS
SubQuery Project uploaded to IPFS: QmZ3q7YZSmhwBiot4PQCK3c7Z6HkteswN2Py58gkkZ8kNd //CID
Note: With @subql/cli
version 1.3.0 or above, when using subql publish
, a copy of the project's IPFS CID
will be stored in a file in your project directory. The naming of the file will be consistent with your project.yaml. For example, if your manfiest file is named project.yaml
, the IPFS file will be named .project-cid
.
IPFS 배포
IPFS 배포는 분산 네트워크에서 SubQuery 프로젝트의 독립적이고 고유한 존재를 나타냅니다. 따라서 프로젝트의 코드를 변경하면 고유성에 영향을 줍니다. 비즈니스 로직을 조정해야 하는 경우 매핑 기능을 변경하려면 프로젝트를 다시 게시해야 하며 CID
가 변경됩니다.
For now, to view the project you have published, use a REST
api tool such as Postman, and use the POST
method with the following example URL to retrieve it:https://ipfs.subquery.network/ipfs/api/v0/cat?arg=<YOUR_PROJECT_CID>
.
You should see the example project deployment as below.
이 배포는 매니페스트 파일과 매우 유사합니다. 이러한 설명 필드를 예상할 수 있으며 네트워크 및 사전 끝점은 프로젝트 실행 결과에 직접적인 영향을 미치지 않았기 때문에 제거되었습니다.
로컬 프로젝트에서 사용된 파일은 압축되어 IPFS에도 게시되었습니다.
dataSources:
- kind: substrate/Runtime
mapping:
file: ipfs://QmTTJKrMVzCZqmRCd5xKHbKymtQQnHZierBMHLtHHGyjLy
handlers:
- handler: handleBlock
kind: substrate/BlockHandler
- filter:
method: Deposit
module: balances
handler: handleEvent
kind: substrate/EventHandler
- handler: handleCall
kind: substrate/CallHandler
startBlock: 8973820
network:
genesisHash: "0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"
schema:
file: ipfs://QmTP5BjtxETVqvU4MkRxmgf8NbceB17WtydS6oQeHBCyjz
specVersion: 0.2.0
Deploy your SubQuery project in the Managed Service
Login to SubQuery Projects
Before starting, please make sure that your SubQuery project codebase is published to IPFS.
To create your first project, head to SubQuery Managed Service. You'll need to authenticate with your GitHub account to login.
On first login, you will be asked to authorize SubQuery. We only need your email address to identify your account, and we don't use any other data from your GitHub account for any other reasons. In this step, you can also request or grant access to your GitHub Organization account so you can post SubQuery projects under your GitHub Organization instead of your personal account.
SubQuery Projects is where you manage all your hosted projects uploaded to the SubQuery platform. You can create, delete, and even upgrade projects all from this application.
If you have a GitHub Organization accounts connected, you can use the switcher on the header to change between your personal account and your GitHub Organization account. Projects created in a GitHub Organization account are shared between members in that GitHub Organization. To connect your GitHub Organization account, you can follow the steps here.
Create Your First Project
There are two methods to create a project in the SubQuery Managed Service: you can use the UI or directly via the subql
cli tool
Using the UI
Start by clicking on "Create Project". You'll be taken to the new project form. Please enter the following (you can change this in the future):
- Project Name: Name your project.
- Description: Provide a description of your project.
- Database: Premium customers can access dedicated databases to host production SubQuery projects from. If this interests you, you can contact sales@subquery.network to have this setting enabled.
- Visible in Explorer: If selected, this will show the project from the public SubQuery explorer to share with the community.
Create your project and you'll see it on your SubQuery Project's list. Next, we just need to deploy a new version of it.
Using the CLI
You can also use @subql/cli
to publish your project to our Managed Service. This requires:
@subql/cli
version 1.1.0 or above.- A valid SUBQL_ACCESS_TOKEN ready.
// Creating a project using the CLI
$ subql project:create-project
// OR using non-interactive, it will prompt you if the required fields are missing
$ subql project:create-project
--apiVersion=apiVersion Api version is default to 2
--description=description Enter description
--gitRepo=gitRepo Enter git repository
--org=org Enter organization name
--projectName=projectName Enter project name
Deploy your First Version
There are three methods to deploy a new version of your project to the SubQuery Managed Service, you can use the UI or directly, via the subql
cli tool, or using an automated GitHub Action.
Using the UI
While creating a project will setup the display behaviour of the project, you must deploy a version of it before it becomes operational. Deploying a version triggers a new SubQuery indexing operation to start, and sets up the required query service to start accepting GraphQL requests. You can also deploy new versions to existing projects here.
With your new project, you'll see a "Deploy your first version" button. Click this, and fill in the required information about the deployment:
- CID: Provide your IPFS deployment CID (without the leading
ipfs://
). This can be acquired by runningsubql publish
with the CLI. The rest of the fields should then auto-populate. - Manifest: The details are obtained from the contents of the provided CID.
- Override Network and Dictionary Endpoints: You can override the endpoints in your project manifest here.
- Indexer Version: This is the version of SubQuery's node service that you want to run this SubQuery on. See
@subql/node
. - Query Version: This is the version of SubQuery's query service that you want to run this SubQuery on. See
@subql/query
. - Advanced Settings: There are numerous advanced settings which are explained via the inbuild help feature.
If deployed successfully, you'll see the indexer start working and report back progress on indexing the current chain. This process may take time until it reaches 100%.
Using the CLI
You can also use @subql/cli
to create a new deployment of your project to our Managed Service. This requires:
@subql/cli
version 1.1.0 or above.- A valid SUBQL_ACCESS_TOKEN ready.
// Deploy using the CLI
$ subql deployment:deploy
// OR Deploy using non-interactive CLI
$ subql deployment:deploy
-d, --useDefaults Use default values for indexerVerion, queryVersion, dictionary, endpoint
--dict=dict Enter dictionary
--endpoint=endpoint Enter endpoint
--indexerVersion=indexerVersion Enter indexer-version
--ipfsCID=ipfsCID Enter IPFS CID
--org=org Enter organization name
--projectName=projectName Enter project name
--queryVersion=queryVersion Enter query-version
--type=(stage|primary) [default: primary]
Using GitHub actions
With the introduction of the deployment feature for the CLI, we've added a Default Action Workflow to the starter project in GitHub that will allow you to publish and deploy your changes automatically:
- Step 1: After pushing your project to GitHub, create
DEPLOYMENT
environment on GitHub, and add the secret SUBQL_ACCESS_TOKEN to it. - Step 2: Create a project on SubQuery Managed Service, this can be done using the the UI or CLI.
- Step 3: Once your project is created, navigate to the GitHub Actions page for your project, and select the workflow
CLI deploy
- Step 4: You'll see an input field where you can enter the unique code of your project created on SubQuery Projects, you can get the code from the URL in SubQuery's Managed Service SubQuery Managed Service. The code is based on the name of your project, where spaces are replaced with hyphens
-
. e.g.my project name
becomesmy-project-name
- Once the workflow is complete, you should be see your project deployed to our Managed Service
A common approach is to extend the default GitHub Action to automatically deploy changes to our Managed Service when code is merged into main. The following change to the GitHub Action workflow do this:
on:
push:
branches:
- main
jobs:
deploy:
name: CLI Deploy
...
다음 단계 - 프로젝트 연결하기
배포가 성공적으로 완료되고 노드가 체인에서 데이터를 인덱스화하면 표출된 GraphQL 쿼리 엔드포인트를 통해 프로젝트에 접속할 수 있습니다.
프로젝트 제목 옆에 있는 3개의 점을 클릭하여 SubQuery 탐색기로 표시할 수도 있습니다. There you can use the in-browser playground to get started - read more about how to use our Explorer here.
Add GitHub Organization Account to SubQuery Projects
It is common to publish your SubQuery project under the name of your GitHub Organization account rather than your personal GitHub account. At any point your can change your currently selected account on SubQuery Managed Service using the account switcher.
If you can't see your GitHub Organization account listed in the switcher, the you may need to grant access to SubQuery for your GitHub Organization (or request it from an administrator). To do this, you first need to revoke permissions from your GitHub account to the SubQuery Application. Then, login to your account settings in GitHub, go to Applications, and under the Authorized OAuth Apps tab, revoke SubQuery - you can follow the exact steps here. Don't worry, this will not delete your SubQuery project and you will not lose any data.
Once you have revoked access, log out of SubQuery Managed Service and log back in again. You should be redirected to a page titled Authorize SubQuery where you can request or grant SubQuery access to your GitHub Organization account. If you don't have admin permissions, you must make a request for an adminstrator to enable this for you.
Once this request has been approved by your administrator (or if are able to grant it youself), you will see the correct GitHub Organization account in the account switcher.