From 2fde184a4d4644f873d52c5ac3aed6b3affaa237 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 2 Aug 2023 15:15:41 +0300 Subject: [PATCH] Extend docker-compose configs with new config when front is running externally --- CHANGELOG.md | 2 + ...ker-compose-no-build-external-frontend.yml | 83 +++++++++++++++++++ .../docker-compose-no-build-frontend.yml | 4 +- docker-compose/envs/common-stats.env | 1 - .../{nginx.conf => default.conf.template} | 2 +- .../services/docker-compose-nginx.yml | 8 +- .../services/docker-compose-stats.yml | 6 +- 7 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 docker-compose/docker-compose-no-build-external-frontend.yml rename docker-compose/proxy/{nginx.conf => default.conf.template} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33496ee991..811490b274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### Chore +- [#8100](https://github.com/blockscout/blockscout/pull/8100) - Extend docker-compose configs with new config when front is running externally +
Dependencies version bumps diff --git a/docker-compose/docker-compose-no-build-external-frontend.yml b/docker-compose/docker-compose-no-build-external-frontend.yml new file mode 100644 index 0000000000..35dbc93a81 --- /dev/null +++ b/docker-compose/docker-compose-no-build-external-frontend.yml @@ -0,0 +1,83 @@ +version: '3.8' + +services: + redis_db: + extends: + file: ./services/docker-compose-redis.yml + service: redis_db + + db: + extends: + file: ./services/docker-compose-db.yml + service: db + + backend: + depends_on: + - db + - smart-contract-verifier + - redis_db + image: blockscout/blockscout:${DOCKER_TAG:-master} + pull_policy: always + restart: always + stop_grace_period: 5m + container_name: 'blockscout' + links: + - db:database + command: sh -c "bin/blockscout eval \"Elixir.Explorer.ReleaseTasks.create_and_migrate()\" && bin/blockscout start" + extra_hosts: + - 'host.docker.internal:host-gateway' + env_file: + - ./envs/common-blockscout.env + environment: + ETHEREUM_JSONRPC_VARIANT: 'ganache' + ETHEREUM_JSONRPC_HTTP_URL: http://host.docker.internal:8545/ + ETHEREUM_JSONRPC_WS_URL: ws://host.docker.internal:8545/ + INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER: 'true' + INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER: 'true' + DATABASE_URL: postgresql://postgres:@host.docker.internal:7432/blockscout?ssl=false + ECTO_USE_SSL: 'false' + SECRET_KEY_BASE: '56NtB48ear7+wMSf0IQuWDAAazhpb31qyc7GiyspBP2vh7t5zlCsF5QDv76chXeN' + CHAIN_ID: '1337' + API_V2_ENABLED: 'true' + MIX_ENV: 'prod' + ports: + - 4000:4000 + volumes: + - ./logs/:/app/logs/ + + smart-contract-verifier: + extends: + file: ./services/docker-compose-smart-contract-verifier.yml + service: smart-contract-verifier + + visualizer: + extends: + file: ./services/docker-compose-visualizer.yml + service: visualizer + + sig-provider: + extends: + file: ./services/docker-compose-sig-provider.yml + service: sig-provider + + stats-db: + depends_on: + - backend + extends: + file: ./services/docker-compose-stats.yml + service: stats-db + + stats: + depends_on: + - stats-db + extends: + file: ./services/docker-compose-stats.yml + service: stats + + proxy: + depends_on: + - backend + - stats + extends: + file: ./services/docker-compose-nginx.yml + service: proxy \ No newline at end of file diff --git a/docker-compose/docker-compose-no-build-frontend.yml b/docker-compose/docker-compose-no-build-frontend.yml index e52017c7f7..76ae066b38 100644 --- a/docker-compose/docker-compose-no-build-frontend.yml +++ b/docker-compose/docker-compose-no-build-frontend.yml @@ -76,14 +76,16 @@ services: stats: depends_on: - - backend + - stats-db extends: file: ./services/docker-compose-stats.yml service: stats proxy: depends_on: + - backend - frontend + - stats extends: file: ./services/docker-compose-nginx.yml service: proxy diff --git a/docker-compose/envs/common-stats.env b/docker-compose/envs/common-stats.env index aa1f48225e..f5eed636ba 100644 --- a/docker-compose/envs/common-stats.env +++ b/docker-compose/envs/common-stats.env @@ -15,7 +15,6 @@ STATS__CREATE_DATABASE=false STATS__RUN_MIGRATIONS=false STATS__DEFAULT_SCHEDULE=0 0 1 * * * * STATS__FORCE_UPDATE_ON_START=false -STATS__CHARTS_CONFIG=config/charts.toml STATS__METRICS__ENABLED=false STATS__METRICS__ADDR=0.0.0.0:6060 diff --git a/docker-compose/proxy/nginx.conf b/docker-compose/proxy/default.conf.template similarity index 97% rename from docker-compose/proxy/nginx.conf rename to docker-compose/proxy/default.conf.template index d20a44c819..3967119647 100644 --- a/docker-compose/proxy/nginx.conf +++ b/docker-compose/proxy/default.conf.template @@ -3,7 +3,7 @@ server { server_name localhost; proxy_http_version 1.1; location / { - proxy_pass http://frontend:3000; + proxy_pass ${FRONT_PROXY_PASS}; } location /socket/v2 { proxy_pass http://backend:4000; diff --git a/docker-compose/services/docker-compose-nginx.yml b/docker-compose/services/docker-compose-nginx.yml index 2d2bd87dc1..295913b460 100644 --- a/docker-compose/services/docker-compose-nginx.yml +++ b/docker-compose/services/docker-compose-nginx.yml @@ -3,11 +3,11 @@ version: '3.8' services: proxy: image: nginx + container_name: proxy volumes: - - type: bind - source: ../proxy/nginx.conf - target: /etc/nginx/conf.d/default.conf - read_only: true + - "../proxy:/etc/nginx/templates" + environment: + FRONT_PROXY_PASS: ${FRONT_PROXY_PASS:-http://frontend:3000} ports: - 80:80 - 81:81 diff --git a/docker-compose/services/docker-compose-stats.yml b/docker-compose/services/docker-compose-stats.yml index 4b14419fa6..b6ea6552b1 100644 --- a/docker-compose/services/docker-compose-stats.yml +++ b/docker-compose/services/docker-compose-stats.yml @@ -12,10 +12,10 @@ services: POSTGRES_HOST_AUTH_METHOD: 'trust' ports: - 7433:5432 + volumes: + - ./stats-db-data:/var/lib/postgresql/data/ stats: - depends_on: - - stats-db image: ghcr.io/blockscout/stats:${STATS_DOCKER_TAG:-latest} pull_policy: always platform: linux/amd64 @@ -32,5 +32,3 @@ services: - STATS__RUN_MIGRATIONS=true ports: - 8153:8050 - volumes: - - ./stats-db-data:/var/lib/postgresql/data/