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

feat: docker-compose file without azure dependencies #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,42 @@ $ docker-compose down --volumes
| WS_URL | Node WebSocket url (sf-explorer) |
| HASURA_GRAPHQL_DATABASE_URL | Postgres database url |
| HASURA_GRAPHQL_ADMIN_SECRET | Hasura admin secret Key |

## Local Configuration

It's possible to build the images locally if you don't have access or don't want to use the azure pre-built containers, start docker compose using the following command to get started:

```bash
docker compose -f docker-compose-local.yaml up -d
```

> NOTE: The sugarfunge-node code is pulled directly from github, using the main branch, change to a different one if needed on `docker-compose-local.yaml` file.

## Sugarfunge ERC1155 Integration

We have 6 (six) graphql actions on hasura that maps directly to the `sugarfunge-integration` api, these actions aim to act as a bridge for asset conversion between the sugarfunge and ethereum networks.

To get these actions running you will need to setup the sugarfunge-integration repository on your local machine and configure the API address inside the docker-compose environment settings for graphql-engine:

```yaml
graphql-engine:
image: 'hasura/graphql-engine:v2.6.0.cli-migrations-v3'
ports:
- '8080:8080'
depends_on:
- postgres
restart: always
volumes:
- ./hasura/migrations:/hasura-migrations
- ./hasura/metadata:/hasura-metadata
- ./hasura/seeds:/hasura-seeds
environment:
HASURA_GRAPHQL_DATABASE_URL: ${HASURA_GRAPHQL_DATABASE_URL}
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET}
HASURA_GRAPHQL_ENABLED_LOG_TYPES: "startup, http-log, webhook-log, websocket-log, query-log"
ACTION_BASE_URL: "http://127.0.0.1:3000"
# Replace this environment variable with the sugarfunge-integration api address
ACTION_RESOLVER_API_ENDPOINT: "http://172.17.0.1:9000"
```
132 changes: 132 additions & 0 deletions docker-compose-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
version: '3.6'
services:
postgres:
image: postgres:13
restart: always
environment:
- DATABASE_HOST=${DATABASE_HOST}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql
keycloak:
image: 'quay.io/keycloak/keycloak:15.0.2'
ports:
- "8081:8080"
restart: always
command:
- '-Dkeycloak.profile.feature.upload_scripts=enabled'
- '-Dkeycloak.migration.action=import'
- '-Dkeycloak.migration.provider=singleFile'
- '-Dkeycloak.migration.file=/tmp/master-realm.json'
- '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING'
volumes:
- type: bind
source: './keycloak/master-realm.json'
target: '/tmp/master-realm.json'
environment:
PROXY_ADDRESS_FORWARDING: ${PROXY_ADDRESS_FORWARDING}
DB_VENDOR: ${DB_VENDOR}
DB_ADDR: ${DB_ADDR}
DB_DATABASE: ${DB_DATABASE}
DB_SCHEMA: ${DB_SCHEMA}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
KEYCLOAK_USER: ${KEYCLOAK_USER}
KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD}
graphql-engine:
image: 'hasura/graphql-engine:v2.6.0.cli-migrations-v3'
ports:
- '8080:8080'
depends_on:
- postgres
restart: always
volumes:
- ./hasura/migrations:/hasura-migrations
- ./hasura/metadata:/hasura-metadata
- ./hasura/seeds:/hasura-seeds
environment:
HASURA_GRAPHQL_DATABASE_URL: ${HASURA_GRAPHQL_DATABASE_URL}
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET}
HASURA_GRAPHQL_ENABLED_LOG_TYPES: "startup, http-log, webhook-log, websocket-log, query-log"
ACTION_BASE_URL: "http://127.0.0.1:3000"
ACTION_RESOLVER_API_ENDPOINT: "http://172.17.0.1:9000"
sf-node-alice:
image: sugarfunge-node:latest
build:
context: https://github.com/SugarFunge/sugarfunge-node.git#main
dockerfile: docker/Dockerfile
restart: always
network_mode: "host"
command: ["--chain=local", "--alice", "--base-path=~/tmp/a" ,"--port=30334", "--ws-port", "9944", "--ws-external", "--rpc-external", "--rpc-cors", "all"]
sf-node-bob:
image: sugarfunge-node:latest
build:
context: https://github.com/SugarFunge/sugarfunge-node.git#main
dockerfile: docker/Dockerfile
restart: always
network_mode: "host"
command: ["--bob", "--base-path=~/tmp/a" ,"--port=30335", "--ws-port", "9945", "--ws-external", "--rpc-external", "--rpc-cors", "all", "--bootnodes", "/ip4/127.0.0.1/tcp/30334/p2p/12D3KooWGzN9EZLNkxEVeApishpq8d3pzChPmw9jQ9kra3csTAhk"]
sf-api:
image: 'sugarfunge-api:latest'
build:
context: https://github.com/SugarFunge/sugarfunge-api.git#main
dockerfile: docker/Dockerfile
restart: always
network_mode: 'host'
command: ["-l", "http://0.0.0.0:4000", "-s", "ws://127.0.0.1:9944"]
sf-status:
image: 'sugarfunge-status:latest'
build:
context: https://github.com/SugarFunge/sf-front-end.git#master
dockerfile: docker/Dockerfile
restart: always
network_mode: 'host'
environment:
PORT: ${PORT}
REACT_APP_PROVIDER_SOCKET: ${REACT_APP_PROVIDER_SOCKET}
sf-explorer:
image: 'sugarfunge-explorer:latest'
build:
context: https://github.com/SugarFunge/sugarfunge-explorer.git#master
dockerfile: docker/Dockerfile
restart: always
network_mode: 'host'
environment:
WS_URL: ${WS_URL}
ipfs:
image: 'ipfs/go-ipfs:master-2021-11-17-0c2f9d5'
restart: always
ports:
- "4001:4001"
- "8001:8080"
- "5001:5001"
volumes:
- ./ipfs:/data/ipfs
appsmith:
image: index.docker.io/appsmith/appsmith-ce
ports:
- "7000:80"
- "443:443"
- "9001:9001"
volumes:
- ./stacks:/appsmith-stacks
labels:
com.centurylinklabs.watchtower.enable: "true"
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
auto_update:
image: containrrr/watchtower:latest-dev
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --schedule "0 0 * ? * *" --label-enable --cleanup
restart: unless-stopped
volumes:
postgres_data:
66 changes: 66 additions & 0 deletions hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
type Mutation {
erc1155_batch_transfer(
from: String!
to: String!
amounts: [Int!]
ids: [Int!]
data: [ERC1155TokenMetadata!]
): ERC1155TransactionOutput
}

type Mutation {
erc1155_batch_wrap(
from: String!
amounts: [Int!]
ids: [Int!]
data: [ERC1155TokenMetadata!]
): ERC1155TransactionOutput
}

type Mutation {
erc1155_mint(
account: String!
amount: Int!
id: Int!
data: ERC1155TokenMetadata!
): ERC1155TransactionOutput
}

type Mutation {
erc1155_transfer(
from: String!
to: String!
amount: Int!
id: Int!
data: ERC1155TokenMetadata!
): ERC1155TransactionOutput
}

type Mutation {
erc1155_unwrap(
id: Int!
amount: Int!
recipient_address: String!
data: ERC1155TokenMetadata!
): ERC1155TransactionOutput
}

type Mutation {
erc1155_wrap(
from: String!
amount: Int!
id: Int!
data: ERC1155TokenMetadata!
): ERC1155TransactionOutput
}

input ERC1155TokenMetadata {
name: String!
symbol: String!
decimals: Int!
}

type ERC1155TransactionOutput {
tx: String!
}

134 changes: 131 additions & 3 deletions hasura/metadata/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,134 @@
actions: []
actions:
- name: erc1155_batch_transfer
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/batch_transfer_nft'
request_transform:
body:
action: transform
template: |-
{
"from": {{$body.input.from}},
"to": {{$body.input.to}},
"amounts": {{$body.input.amounts}},
"ids": {{$body.input.ids}},
"data": {{$body.input.data}}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
- name: erc1155_batch_wrap
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/batch_wrap_1155'
request_transform:
body:
action: transform
template: |-
{
"from": {{$body.input.from}},
"amounts": {{$body.input.amounts}},
"ids": {{$body.input.ids}},
"data": {{$body.input.data}}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
- name: erc1155_mint
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/mint_nft'
request_transform:
body:
action: transform
template: |-
{
"account": {{$body.input.account}},
"amount": {{$body.input.amount}},
"id": {{$body.input.id}},
"data": {
"name": {{$body.input.data.name}},
"symbol": {{$body.input.data.symbol}},
"decimals": {{$body.input.data.decimals}}
}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
- name: erc1155_transfer
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/transfer_nft'
request_transform:
body:
action: transform
template: |-
{
"from": {{$body.input.from}},
"to": {{$body.input.to}},
"amount": {{$body.input.amount}},
"id": {{$body.input.id}},
"data": {
"name": {{$body.input.data.name}},
"symbol": {{$body.input.data.symbol}},
"decimals": {{$body.input.data.decimals}}
}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
- name: erc1155_unwrap
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/unwrap_1155'
request_transform:
body:
action: transform
template: |-
{
"id": {{$body.input.id}},
"amount": {{$body.input.amount}},
"recipient_address": {{$body.input.recipient_address}},
"data": {
"name": {{$body.input.data.name}},
"symbol": {{$body.input.data.symbol}},
"decimals": {{$body.input.data.decimals}}
}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
- name: erc1155_wrap
definition:
kind: synchronous
handler: '{{ACTION_RESOLVER_API_ENDPOINT}}/wrap_1155'
request_transform:
body:
action: transform
template: |-
{
"from": {{$body.input.from}},
"amount": {{$body.input.amount}},
"id": {{$body.input.id}},
"data": {
"name": {{$body.input.data.name}},
"symbol": {{$body.input.data.symbol}},
"decimals": {{$body.input.data.decimals}}
}
}
method: POST
version: 2
query_params: {}
template_engine: Kriti
custom_types:
enums: []
input_objects: []
objects: []
input_objects:
- name: ERC1155TokenMetadata
objects:
- name: ERC1155TransactionOutput
scalars: []