Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add demo_squid_cloud template #1057

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,38 @@
"DIPDUP_DEBUG": "1"
}
},
{
"name": "demo_squid_cloud: run",
"type": "debugpy",
"request": "launch",
"module": "dipdup",
"args": [
"-e",
".env",
"run"
],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/demo_squid_cloud",
"env": {
"DIPDUP_DEBUG": "1"
}
},
{
"name": "demo_squid_cloud: init",
"type": "debugpy",
"request": "launch",
"module": "dipdup",
"args": [
"-e",
".env",
"init"
],
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/demo_squid_cloud",
"env": {
"DIPDUP_DEBUG": "1"
}
},
{
"name": "demo_evm_events: run",
"type": "debugpy",
Expand Down
1 change: 1 addition & 0 deletions docs/8.examples/_demos_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
| name | network | description | source |
|-|-|-|-|
| demo_blank | | Empty config for a fresh start | [link](https://github.com/dipdup-io/dipdup/tree/8.0.0b3/src/demo_blank) |
| demo_squid_cloud | | Deploying DipDup to Squid Cloud | [link](https://github.com/dipdup-io/dipdup/tree/8.0.0b3/src/demo_squid_cloud) |
| demo_evm_events | EVM | ERC-20 token transfers (from event logs) | [link](https://github.com/dipdup-io/dipdup/tree/8.0.0b3/src/demo_evm_events) |
| demo_evm_transactions | EVM | ERC-20 token transfers (from transactions) | [link](https://github.com/dipdup-io/dipdup/tree/8.0.0b3/src/demo_evm_transactions) |
| demo_evm_uniswap | EVM | Uniswap V3 pools, positions, etc. (advanced, uses TimescaleDB) | [link](https://github.com/dipdup-io/dipdup/tree/8.0.0b3/src/demo_evm_uniswap) |
Expand Down
22 changes: 22 additions & 0 deletions src/demo_squid_cloud/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ignore all
*

# Add metadata and build files
!demo_squid_cloud
!pyproject.toml
!*.lock
!README.md

# Add Python code
!**/*.py
**/.*_cache
**/__pycache__

# Add configs and scripts (but not env!)
!**/*.graphql
!**/*.json
!**/*.sql
!**/*.yaml
!**/*.yml
!**/*.j2
!**/.keep
29 changes: 29 additions & 0 deletions src/demo_squid_cloud/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Ignore all
*
!*/

# Add metadata and build files
!demo_squid_cloud
!.gitignore
!.dockerignore
!py.typed
!**/Dockerfile
!**/Makefile
!**/pyproject.toml
!**/*.lock
!**/README.md
!**/.keep

# Add Python code
!**/*.py
**/.*_cache
**/__pycache__

# Add configs and scripts (but not env!)
!**/*.graphql
!**/*.json
!**/*.sql
!**/*.yaml
!**/*.yml
!**/*.j2
!**/*.env.default
45 changes: 45 additions & 0 deletions src/demo_squid_cloud/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.PHONY: $(MAKECMDGOALS)
MAKEFLAGS += --no-print-directory
##
## 🚧 DipDup developer tools
##
PACKAGE=demo_squid_cloud
TAG=latest
COMPOSE=deploy/compose.yaml

help: ## Show this help (default)
@grep -Fh "##" $(MAKEFILE_LIST) | grep -Fv grep -F | sed -e 's/\\$$//' | sed -e 's/##//'

all: ## Run an entire CI pipeline
make format lint

format: ## Format with all tools
make black

lint: ## Lint with all tools
make ruff mypy

##

black: ## Format with black
black .

ruff: ## Lint with ruff
ruff check --fix .

mypy: ## Lint with mypy
mypy --no-incremental --exclude ${PACKAGE} .

##

image: ## Build Docker image
docker buildx build . -t ${PACKAGE}:${TAG} --load

up: ## Start Compose stack
docker-compose -f ${COMPOSE} up -d --build
docker-compose -f ${COMPOSE} logs -f

down: ## Stop Compose stack
docker-compose -f ${COMPOSE} down

##
49 changes: 49 additions & 0 deletions src/demo_squid_cloud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# demo_squid_cloud

Deploying DipDup to Squid Cloud

## Installation

This project is based on [DipDup](https://dipdup.io), a framework for building featureful dapps.

You need a Linux/macOS system with Python 3.12 installed. To install DipDup with pipx or use our installer:

```shell
curl -Lsf https://dipdup.io/install.py | python3.12
```

See the [Installation](https://dipdup.io/docs/installation) page for all options.

## Usage

Run the indexer in memory:

```shell
dipdup run
```

Store data in SQLite database:

```shell
dipdup -c . -c configs/dipdup.sqlite.yaml run
```

Or spawn a Compose stack with PostgreSQL and Hasura:

```shell
cd deploy
cp .env.default .env
# Edit .env file before running
docker-compose up
```

## Development setup

To set up the development environment:

```shell
pdm install
$(pdm venv activate)
```

Run `make all` to run full CI check or `make help` to see other available commands.
Empty file.
Empty file added src/demo_squid_cloud/abi/.keep
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions src/demo_squid_cloud/configs/dipdup.compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
database:
kind: postgres
host: ${POSTGRES_HOST:-db}
port: 5432
user: ${POSTGRES_USER:-dipdup}
password: ${POSTGRES_PASSWORD}
database: ${POSTGRES_DB:-dipdup}

hasura:
url: http://${HASURA_HOST:-hasura}:8080
admin_secret: ${HASURA_SECRET}
allow_aggregations: ${HASURA_ALLOW_AGGREGATIONS:-true}
select_limit: ${HASURA_SELECT_LIMIT:-10000}
camel_case: ${HASURA_CAMEL_CASE:-true}

sentry:
dsn: ${SENTRY_DSN:-''}
environment: ${SENTRY_ENVIRONMENT:-''}

prometheus:
host: 0.0.0.0

api:
host: 0.0.0.0
3 changes: 3 additions & 0 deletions src/demo_squid_cloud/configs/dipdup.sqlite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
database:
kind: sqlite
path: ${SQLITE_PATH:-/tmp/demo_squid_cloud.sqlite}
25 changes: 25 additions & 0 deletions src/demo_squid_cloud/configs/dipdup.squid-cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
database:
kind: postgres
host: ${DB_HOST:-db}
port: ${DB_PORT}
user: ${DB_USER:-dipdup}
password: ${DB_PASS}
database: ${DB_NAME:-dipdup}

hasura:
url: http://${HASURA_HOST:-hasura}:8080
admin_secret: ${HASURA_GRAPHQL_ADMIN_SECRET}
allow_aggregations: ${HASURA_ALLOW_AGGREGATIONS:-true}
select_limit: ${HASURA_SELECT_LIMIT:-10000}
camel_case: ${HASURA_CAMEL_CASE:-true}

sentry:
dsn: ${SENTRY_DSN:-''}
environment: ${SENTRY_ENVIRONMENT:-''}

prometheus:
host: 0.0.0.0
port: 3000

api:
host: 0.0.0.0
24 changes: 24 additions & 0 deletions src/demo_squid_cloud/configs/dipdup.swarm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
database:
kind: postgres
host: ${POSTGRES_HOST:-demo_squid_cloud_db}
port: 5432
user: ${POSTGRES_USER:-dipdup}
password: ${POSTGRES_PASSWORD}
database: ${POSTGRES_DB:-dipdup}

hasura:
url: http://${HASURA_HOST:-demo_squid_cloud_hasura}:8080
admin_secret: ${HASURA_SECRET}
allow_aggregations: ${HASURA_ALLOW_AGGREGATIONS:-false}
select_limit: ${HASURA_SELECT_LIMIT:-100}
camel_case: ${HASURA_CAMEL_CASE:-true}

sentry:
dsn: ${SENTRY_DSN:-''}
environment: ${SENTRY_ENVIRONMENT:-''}

prometheus:
host: 0.0.0.0

api:
host: 0.0.0.0
18 changes: 18 additions & 0 deletions src/demo_squid_cloud/configs/replay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To refresh existing project run `dipdup init --base --force` after modifying this file.
# To generate a new project from this replay run `dipdup new --replay <path_to_file>`.
#
spec_version: 3.0
replay:
dipdup_version: 8
template: demo_squid_cloud
package: demo_squid_cloud
version: 0.0.1
description: Deploying DipDup to Squid Cloud
license: MIT
name: John Doe
email: john_doe@example.com
postgres_image: postgres:15
postgres_data_path: /var/lib/postgresql/data
hasura_image: hasura/graphql-engine:latest
line_length: 120
package_manager: pdm
14 changes: 14 additions & 0 deletions src/demo_squid_cloud/deploy/.env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This env file was generated automatically by DipDup. Do not edit it!
# Create a copy with .env extension, fill it with your values and run DipDup with `--env-file` option.
#
HASURA_ALLOW_AGGREGATIONS=true
HASURA_CAMEL_CASE=true
HASURA_HOST=hasura
HASURA_SECRET=
HASURA_SELECT_LIMIT=10000
POSTGRES_DB=dipdup
POSTGRES_HOST=db
POSTGRES_PASSWORD=
POSTGRES_USER=dipdup
SENTRY_DSN=''
SENTRY_ENVIRONMENT=''
Empty file.
9 changes: 9 additions & 0 deletions src/demo_squid_cloud/deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM dipdup/dipdup:8
# FROM ghcr.io/dipdup-io/dipdup:8
# FROM ghcr.io/dipdup-io/dipdup:next

# COPY --chown=dipdup pyproject.toml README.md .
# RUN pip install .

COPY --chown=dipdup . demo_squid_cloud
WORKDIR demo_squid_cloud
19 changes: 19 additions & 0 deletions src/demo_squid_cloud/deploy/compose.sqlite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3.8"
name: demo_squid_cloud

services:
dipdup:
build:
context: ..
dockerfile: deploy/Dockerfile
command: ["-c", "dipdup.yaml", "-c", "configs/dipdup.sqlite.yaml", "run"]
restart: always
env_file: .env
ports:
- 46339
- 9000
volumes:
- sqlite:${SQLITE_PATH:-/tmp/demo_squid_cloud.sqlite}

volumes:
sqlite:
Loading
Loading