diff --git a/.gitignore b/.gitignore index 323d985f..31e01adb 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ documentation/docs/dist documentation/vocs.config.ts* graphql/node_modules rindexer_rust_playground/generated_csv/*/*.csv +.env +!.env.example diff --git a/documentation/docs/pages/docs/deploying/railway.mdx b/documentation/docs/pages/docs/deploying/railway.mdx index 84ea9571..734ae7f7 100644 --- a/documentation/docs/pages/docs/deploying/railway.mdx +++ b/documentation/docs/pages/docs/deploying/railway.mdx @@ -1 +1,64 @@ -# Railway \ No newline at end of file +# Railway + +## One-click Deploy Example + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/Rqrlcf?referralCode=eD4laT) + +## Deploy an example project + +https://github.com/joshstevens19/rindexer/tree/master/providers/railway + +1. Clone the relevant directory + + ```bash + # this will clone the railway directory + mkdir rindexer-railway && cd rindexer-railway + git clone \ + --depth=1 \ + --no-checkout \ + --filter=tree:0 \ + https://github.com/joshstevens19/rindexer . + git sparse-checkout set --no-cone providers/railway . + git checkout && cp -r providers/railway/* . && rm -rf providers + ``` + +2. Initialize a new Railway project + + ```bash + railway init --name rindexer-example + ``` + +3. Create a service and link it to the project + + ```bash + railway up --detach + railway link --name rindexer-example --enviroment production + ``` + +4. Create a Postgres database + + ```bash + railway add --database postgre-sql + ``` + +5. Configure environment variables + + ```bash + railway open + ``` + + - then open the service "Variables" tab and click on "Add Variable Reference" and select `DATABASE_URL`, + - postfix `?sslmode=diable` to the end of the value. It should look like this: `${{Postgres.DATABASE_URL}}?sslmode=disable`, + - hit "Deploy" or Shift+Enter. + +6. Create a domain to access GraphQL Playground + + ```bash + railway domain + ``` + +7. Redeploy the service + + ```bash + railway up + ``` diff --git a/documentation/vocs.config.ts b/documentation/vocs.config.ts index bc1881b7..475c7af6 100644 --- a/documentation/vocs.config.ts +++ b/documentation/vocs.config.ts @@ -95,7 +95,7 @@ export default defineConfig({ { text: 'Deploying', items: [ - { text: 'Railway - coming soon' }, + { text: 'Railway', link: '/docs/deploying/railway' }, { text: 'AWS - coming soon' }, { text: 'GCP - coming soon' }, ], diff --git a/providers/railway/.dockerignore b/providers/railway/.dockerignore new file mode 100644 index 00000000..d25a771b --- /dev/null +++ b/providers/railway/.dockerignore @@ -0,0 +1,5 @@ +* + +!Dockerfile +!.dockerignore +!example-app diff --git a/providers/railway/Dockerfile b/providers/railway/Dockerfile new file mode 100644 index 00000000..03322153 --- /dev/null +++ b/providers/railway/Dockerfile @@ -0,0 +1,16 @@ +# syntax = docker/dockerfile:1.6 +FROM ghcr.io/joshstevens19/rindexer:latest AS rindexer + +ARG PROJECT_PATH="./example-app" + +WORKDIR /usr/src/app + +COPY ${PROJECT_PATH} /usr/src/app/rindexer-app + +ARG PORT="3001" +ENV PORT=${PORT} + +EXPOSE ${PORT} + +ENTRYPOINT ["/app/rindexer"] +CMD ["start", "-p", "./rindexer-app", "all"] diff --git a/providers/railway/README.md b/providers/railway/README.md new file mode 100644 index 00000000..198057b1 --- /dev/null +++ b/providers/railway/README.md @@ -0,0 +1,64 @@ +# Railway + +## One-click Deploy Example + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/Rqrlcf?referralCode=eD4laT) + +## Deploy an example project + + + +1. Clone the relevant directory + + ```bash + # this will clone the railway directory + mkdir rindexer-railway && cd rindexer-railway + git clone \ + --depth=1 \ + --no-checkout \ + --filter=tree:0 \ + https://github.com/joshstevens19/rindexer . + git sparse-checkout set --no-cone providers/railway . + git checkout && cp -r providers/railway/* . && rm -rf providers + ``` + +2. Initialize a new Railway project + + ```bash + railway init --name rindexer-example + ``` + +3. Create a service and link it to the project + + ```bash + railway up --detach + railway link --name rindexer-example --enviroment production + ``` + +4. Create a Postgres database + + ```bash + railway add --database postgre-sql + ``` + +5. Configure environment variables + + ```bash + railway open + ``` + +- then open the service "Variables" tab and click on "Add Variable Reference" and select `DATABASE_URL`, +- postfix `?sslmode=diable` to the end of the value. It should look like this: `${{Postgres.DATABASE_URL}}?sslmode=disable`, +- hit "Deploy" or Shift+Enter. + +6. Create a domain to access GraphQL Playground + + ```bash + railway domain + ``` + +7. Redeploy the service + + ```bash + railway up + ``` diff --git a/providers/railway/aws/.gitkeep b/providers/railway/aws/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/providers/railway/example-app/erc20.abi.json b/providers/railway/example-app/erc20.abi.json new file mode 100644 index 00000000..eabaa761 --- /dev/null +++ b/providers/railway/example-app/erc20.abi.json @@ -0,0 +1,153 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "guy", "type": "address" }, + { "name": "wad", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "src", "type": "address" }, + { "name": "dst", "type": "address" }, + { "name": "wad", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "name": "wad", "type": "uint256" }], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "name": "dst", "type": "address" }, + { "name": "wad", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "deposit", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "name": "", "type": "address" }, + { "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { "payable": true, "stateMutability": "payable", "type": "fallback" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "src", "type": "address" }, + { "indexed": true, "name": "guy", "type": "address" }, + { "indexed": false, "name": "wad", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "src", "type": "address" }, + { "indexed": true, "name": "dst", "type": "address" }, + { "indexed": false, "name": "wad", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "dst", "type": "address" }, + { "indexed": false, "name": "wad", "type": "uint256" } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "name": "src", "type": "address" }, + { "indexed": false, "name": "wad", "type": "uint256" } + ], + "name": "Withdrawal", + "type": "event" + } +] diff --git a/providers/railway/example-app/rindexer.yaml b/providers/railway/example-app/rindexer.yaml new file mode 100644 index 00000000..09903eb8 --- /dev/null +++ b/providers/railway/example-app/rindexer.yaml @@ -0,0 +1,22 @@ +name: wETHIndexer +description: My first rindexer project +repository: https://github.com/joshstevens19/rindexer +project_type: no-code +networks: + - name: sepolia + chain_id: 11155111 + rpc: https://sepolia.gateway.tenderly.co +storage: + postgres: + enabled: true +contracts: + - name: SepoliaWETH + details: + - network: sepolia + address: 0x097D90c9d3E0B50Ca60e1ae45F6A81010f9FB534 + abi: ./erc20.abi.json + include_events: + - Deposit + - Approval + - Transfer + - Withdrawal diff --git a/providers/railway/railway.toml b/providers/railway/railway.toml new file mode 100644 index 00000000..9b7b38dc --- /dev/null +++ b/providers/railway/railway.toml @@ -0,0 +1,12 @@ +#: schema https://railway.app/railway.schema.json +[build] +builder = "DOCKERFILE" +buildEnvironment = "V2" +dockerfilePath = "./Dockerfile" + +[deploy] +runtime = "V2" +numReplicas = 1 +sleepApplication = false +restartPolicyMaxRetries = 10 +restartPolicyType = "ON_FAILURE"