Skip to content

Commit

Permalink
Add PGAdmin services and update scripts.
Browse files Browse the repository at this point in the history
This commit introduces PGAdmin to the Docker compose configuration, making local development easier. It also includes changes in the package.json scripts to utilize Docker compose. Notably, the commit incorporates an updated 'docker:dev:local' script and a new ignore file for Docker.
  • Loading branch information
jorgecuesta committed Jun 27, 2024
1 parent 438db24 commit 1f66f46
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 10 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# root and vendor modules
node_modules
*/**/node_modules

# generated code
dist
src/types

# not needed
docs
.run
.github
*.md
*/**/.md
*/**/.png
*/**/.jpg
8 changes: 8 additions & 0 deletions .run/Localdev.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Localdev" type="NodeJSConfigurationType" application-parameters="-f=./ --db-schema=app --workers=4 --batch-size=30 --unfinalized-blocks=true" path-to-js-file="vendor/subql-cosmos/packages/node/bin/run" working-dir="$PROJECT_DIR$">
<envs>
<env name="NODE_ENV" value="develop" />
</envs>
<method v="2" />
</configuration>
</component>
18 changes: 17 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ services:
timeout: 5s
retries: 5

pgadmin:
image: dpage/pgadmin4:8.8
container_name: pgadmin
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_LISTEN_PORT: 5050
volumes:
- ./docker/postgres/servers.json:/pgadmin4/servers.json
depends_on:
postgres:
condition: service_healthy
ports:
- 5050:5050

# Note: The proxy service is only necessary if you are running a Shannon
# localnet and are unable to use the docker network in bridge mode.
# To use the proxy service you must run the following command on the host
Expand Down Expand Up @@ -85,4 +101,4 @@ services:

volumes:
postgres_data:
driver: local
driver: local
2 changes: 1 addition & 1 deletion docker/node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ ADD ./project.ts schema.graphql /app/
ADD ./scripts/node-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
13 changes: 13 additions & 0 deletions docker/postgres/servers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Servers": {
"1": {
"Name": "[email protected]",
"Group": "Localnet",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "postgres",
"SSLMode": "prefer"
}
}
}
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
"vendor:subql:install": "cd vendor && yarn workspace @subql/node-cosmos install",
"vendor:cosmjs:build": "cd vendor && yarn workspace cosmjs-monorepo-root run build",
"vendor:subql:build": "cd vendor && yarn workspace @subql/node-cosmos run build",
"vendor:clean": "cd vendor && rm -rf node_modules && find ./ -type d -name 'node_modules' -exec sh -c 'rm -rf \"$0\"/*' {} \\;",
"docker:build": "docker-compose build",
"docker:build:no-cache": "docker-compose build --no-cache",
"build": "subql codegen && sed -i 's/\\[key: bigint\\]/\\[key: number\\]/g' ./src/types/proto-interfaces/poktroll/application/application.ts && subql build",
"vendor:clean": "cd vendor && find . -name node_modules | xargs rm -rf && find . -name dist | xargs rm -rf",
"docker:build": "docker compose build",
"docker:build:no-cache": "docker compose build --no-cache",
"build": "subql codegen && sed -i 's/\\[key: bigint\\]/\\[key: number\\]/g' ./src/types/proto-interfaces/poktroll/application/application.ts && subql build",
"build:develop": "NODE_ENV=develop subql codegen && sed -i 's/\\[key: bigint\\]/\\[key: number\\]/g' ./src/types/proto-interfaces/poktroll/application/application.ts && NODE_ENV=develop subql build",
"codegen": "subql codegen",
"docker:start": "docker-compose pull && docker-compose up --remove-orphans",
"docker:stop": "docker-compose down",
"docker:start": "docker compose pull && docker compose up --remove-orphans",
"docker:stop": "docker compose down",
"docker:clean": "yarn docker:stop && docker volume rm pocketdex_postgres_data",
"docker:tunnel": "echo 'if public key auth fails the password is `proxypass`.' && ssh -o StrictHostKeyChecking=no -N -R 26657:localhost:26657 proxyuser@localhost -p 2222",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"docker:dev:local": "docker compose up -d postgres pgadmin graphql-engine",
"dev:docker": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans",
"dev:local": "NODE_ENV=develop node vendor/subql-cosmos/packages/node/bin/run -f=./ --db-schema=app --workers=1 --batch-size=10 --unfinalized-blocks=true",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-cosmos test",
"db:clean": "docker volume rm pocketdex_postgres_data"
"db:clean": "docker compose down -v"
},
"homepage": "https://github.com/subquery/cosmos-subql-starter",
"repository": "github:subquery/cosmos-subql-starter",
Expand Down

0 comments on commit 1f66f46

Please sign in to comment.