@ -10,7 +10,11 @@ ifeq ($(SYSTEM), Linux)
HOST = localhost
e n d i f
DB_URL = postgresql://postgres:@$( HOST) :5432/explorer?ssl= false
i f d e f D A T A B A S E _ U R L
DB_URL = $( DATABASE_URL)
e l s e
DB_URL = postgresql://postgres:@$( HOST) :5432/explorer?ssl= false
e n d i f
BLOCKSCOUT_CONTAINER_PARAMS = -e 'MIX_ENV=prod' \
-e 'DATABASE_URL=$(DB_URL)'
i f e q ( $( SYSTEM ) , L i n u x )
@ -371,6 +375,12 @@ endif
i f d e f C O I N _ N A M E
BLOCKSCOUT_CONTAINER_PARAMS += -e 'COIN_NAME=$(COIN_NAME)'
e n d i f
i f d e f I N D E X E R _ D I S A B L E _ P E N D I N G _ T R A N S A C T I O N S _ F E T C H E R
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER=$(INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER)'
e n d i f
i f d e f I N D E X E R _ D I S A B L E _ I N T E R N A L _ T R A N S A C T I O N S _ F E T C H E R
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=$(INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER)'
e n d i f
HAS_BLOCKSCOUT_IMAGE := $( shell docker images | grep -sw ${ DOCKER_IMAGE } )
build :
@ -395,6 +405,10 @@ migrate: build postgres
PG_EXIST := $( shell docker ps -a --filter name = ${ PG_CONTAINER_NAME } | grep ${ PG_CONTAINER_NAME } )
PG_STARTED := $( shell docker ps --filter name = ${ PG_CONTAINER_NAME } | grep ${ PG_CONTAINER_NAME } )
postgres :
i f d e f D A T A B A S E _ U R L
@echo "==> DATABASE_URL of external DB provided. There is no need to start a container for DB."
@$( MAKE) -f $( THIS_FILE) migrate_only
e l s e
i f d e f P G _ E X I S T
@echo "==> Checking PostrgeSQL container"
i f d e f P G _ S T A R T E D
@ -416,18 +430,37 @@ else
@sleep 1
@$( MAKE) -f $( THIS_FILE) migrate_only
e n d i f
e n d i f
start : build postgres
@echo "==> Starting blockscout"
@docker run --rm --name $( BS_CONTAINER_NAME) \
$( BLOCKSCOUT_CONTAINER_PARAMS) \
-p 4000:4000 \
$( DOCKER_IMAGE) /bin/sh -c "mix do ecto.create, ecto.migrate; mix phx.server"
$( DOCKER_IMAGE) /bin/sh -c "mix phx.server"
BS_STARTED := $( shell docker ps --filter name = ${ BS_CONTAINER_NAME } | grep ${ BS_CONTAINER_NAME } )
stop :
i f d e f B S _ S T A R T E D
@echo "==> Stopping BlockScout container."
@docker stop $( BS_CONTAINER_NAME)
@echo "==> BlockScout container stopped."
e l s e
@echo "==> BlockScout container already stopped before."
e n d i f
i f d e f P G _ S T A R T E D
@echo "==> Stopping Postgres container."
@docker stop $( PG_CONTAINER_NAME)
@echo "==> Postgres container stopped."
e l s e
@echo "==> Postgres container already stopped before."
e n d i f
run : start
.PHONY : build \
migrate \
start \
stop \
postgres \
run