Skip to content

Commit

Permalink
chore: docker compose config
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Sep 25, 2023
1 parent 6b56f39 commit a21f0eb
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 46 deletions.
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:
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

0 comments on commit a21f0eb

Please sign in to comment.