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

chore: docker compose config #18

Merged
merged 3 commits into from
Sep 25, 2023
Merged
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
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ For `production` mode run:
$ npm run build
$ npm run start
```
To verify front-end `App` is running open http://localhost:3010 in your browser. `API` should be available at http://localhost:3000. `Worker` - http://localhost:3001.

Each component can also be started individually. Follow individual packages `README` for details.

## 🐳 Running in Docker
There is a docker compose configuration that allows you to run Block Explorer and all its dependencies in docker. Just run the following command to spin up the whole environment:
```
docker-compose up
```
It will run local Ethereum node, ZkSync Era, Postgres DB and all Block Explorer services.

## 🔍 Verify Block Explorer is up and running

To verify front-end `App` is running open http://localhost:3010 in your browser. `API` should be available at http://localhost:3000. `Worker` - http://localhost:3001.

## 🕵️‍♂️ Testing
Run unit tests for all packages:
```bash
Expand Down
62 changes: 55 additions & 7 deletions packages/worker/docker-compose.yaml → docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
name: block-explorer
services:
app:
build:
context: .
dockerfile: ./packages/app/Dockerfile
command: npm run --prefix packages/app dev -- --host
ports:
- '3010:3010'
depends_on:
- api
restart: unless-stopped

worker:
build:
context: .
dockerfile: ./packages/worker/Dockerfile
target: development-stage
command: npm run dev:debug
command: npm run --prefix packages/worker dev:debug
environment:
- PORT=3001
- LOG_LEVEL=verbose
Expand All @@ -19,15 +31,45 @@ services:
- '9229:9229'
- '9230:9230'
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
- ./packages/worker:/usr/src/app/packages/worker
- /usr/src/app/packages/worker/node_modules
- ./node_modules:/usr/src/worker/node_modules:ro
depends_on:
zksync:
condition: service_healthy
restart: unless-stopped

api:
build:
context: .
dockerfile: ./packages/api/Dockerfile
target: development-stage
command: npm run --prefix packages/api dev:debug
environment:
- PORT=3000
- METRICS_PORT=3005
- LOG_LEVEL=verbose
- NODE_ENV=development
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/block-explorer
ports:
- '3000:3000'
- '3005:3005'
- '9231:9229'
- '9232:9230'
volumes:
- ./packages/api:/usr/src/app/packages/api
- /usr/src/app/packages/api/node_modules
- ./node_modules:/usr/src/api/node_modules:ro
depends_on:
- worker
restart: unless-stopped

postgres:
image: "postgres"
image: "postgres:14"
logging:
driver: none
volumes:
- postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
Expand All @@ -48,7 +90,7 @@ services:
- "8545:8545"
- "8546:8546"
volumes:
- ./volumes/geth:/var/lib/geth/data
- geth:/var/lib/geth/data

zksync:
stdin_open: true
Expand All @@ -64,9 +106,9 @@ services:
- "3051:3051" # JSON RPC WS port
volumes:
# Configs folder bind
- ./volumes/zksync/env/dev:/etc/env/dev
- zksync-config:/etc/env/
# Storage folder bind
- ./volumes/zksync/data:/var/lib/zksync/data
- zksync-data:/var/lib/zksync/data
environment:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/zksync_local
- ETH_CLIENT_WEB3_URL=http://geth:8545
Expand All @@ -76,3 +118,9 @@ services:
timeout: 5s
retries: 120
restart: unless-stopped

volumes:
geth:
postgres:
zksync-config:
zksync-data:
5 changes: 1 addition & 4 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,4 @@ To output performance results to a file use next command:
artillery run ./performance/load-test.yaml -e testnet -o ./performance/29-06/testnet.json
```

for more command options check [official artillery docs](https://www.artillery.io/docs).

### Conventional Commits
We follow the Conventional Commits [specification](https://www.conventionalcommits.org/en/v1.0.0/#specification).
for more command options check [official artillery docs](https://www.artillery.io/docs).
38 changes: 0 additions & 38 deletions packages/api/docker-compose.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions packages/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18.17.1-alpine
ENV NODE_ENV=development

WORKDIR /usr/src/app
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*

COPY --chown=node:node .npmrc .npmrc
COPY --chown=node:node lerna.json ./
COPY --chown=node:node package*.json ./
COPY --chown=node:node ./packages/app/package*.json ./packages/app/
RUN npm ci
COPY --chown=node:node ./packages/app/. ./packages/app
12 changes: 1 addition & 11 deletions packages/worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ $ npm run dev:debug
$ npm run start
```

## Running the app in Docker
There is a docker compose configuration that allows you to run Block Explorer Worker and all its dependencies in docker. Just run the following command to spin up the whole environment:
```
docker-compose up
```
It will run local Ethereum node, ZkSync Era, Postgres DB and Block Explorer Worker.

## Test

```bash
Expand Down Expand Up @@ -90,7 +83,4 @@ Example:
npm run migration:create -name=UpdateTxsFee
```

this command will simply create an empty migration where the custom migration logic can be added.

### Conventional Commits
We follow the Conventional Commits [specification](https://www.conventionalcommits.org/en/v1.0.0/#specification).
this command will simply create an empty migration where the custom migration logic can be added.
Loading