Docker setup Makefile release publish tasks

pull/5202/head
Viktor Baranov 3 years ago
parent cc417fbd64
commit f295519689
  1. 1
      CHANGELOG.md
  2. 69
      docker/Makefile

@ -18,6 +18,7 @@
- [#5154](https://github.com/blockscout/blockscout/pull/5154) - Fix token counters bug
### Chore
- [#5202](https://github.com/blockscout/blockscout/pull/5202) - Docker setup Makefile release/publish tasks
- [#5195](https://github.com/blockscout/blockscout/pull/5195) - Add Berlin, London to the list of default EVM versions
- [#5190](https://github.com/blockscout/blockscout/pull/5190) - Set 8545 as default port everywhere except Ganache JSON RPC variant
- [#5189](https://github.com/blockscout/blockscout/pull/5189) - ENV var to manage pending transactions fetcher switching off

@ -1,10 +1,14 @@
SYSTEM = $(shell uname -s)
HOST = host.docker.internal
DOCKER_IMAGE = blockscout
BS_CONTAINER_NAME = blockscout
PG_CONTAINER_NAME = db
PG_CONTAINER_IMAGE = postgres:13.6
SYSTEM := $(shell uname -s)
HOST := host.docker.internal
DOCKER_REPO := blockscout
APP_NAME := blockscout
BS_CONTAINER_IMAGE := ${APP_NAME}
BS_CONTAINER_NAME := blockscout
PG_CONTAINER_IMAGE := postgres:13.6
PG_CONTAINER_NAME := db
THIS_FILE = $(lastword $(MAKEFILE_LIST))
BS_NEXT_RELEASE = 4.1.2
TAG := $(BS_NEXT_RELEASE)-prerelease-$(shell git log -1 --pretty=format:"%h")
ifeq ($(SYSTEM), Linux)
HOST=localhost
@ -382,21 +386,21 @@ ifdef INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER
BLOCKSCOUT_CONTAINER_PARAMS += -e 'INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=$(INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER)'
endif
HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw "${DOCKER_IMAGE} ")
HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw "${BS_CONTAINER_IMAGE} ")
build:
@echo "==> Checking for blockscout image $(DOCKER_IMAGE)"
@echo "==> Checking for blockscout image $(BS_CONTAINER_IMAGE)"
ifdef HAS_BLOCKSCOUT_IMAGE
@echo "==> Image exist. Using $(DOCKER_IMAGE)"
@echo "==> Image exist. Using $(BS_CONTAINER_IMAGE)"
else
@echo "==> No image found trying to build one..."
@docker build --build-arg COIN="$(COIN)" -f ./Dockerfile -t $(DOCKER_IMAGE) ../
@echo "==> No image found, trying to build one..."
@docker build --build-arg COIN="$(COIN)" -f ./Dockerfile -t $(BS_CONTAINER_IMAGE) ../
endif
migrate_only:
@echo "==> Running migrations"
@docker run --rm \
$(BLOCKSCOUT_CONTAINER_PARAMS) \
$(DOCKER_IMAGE) /bin/sh -c "echo $$MIX_ENV && mix do ecto.create, ecto.migrate"
$(BS_CONTAINER_IMAGE) /bin/sh -c "echo $$MIX_ENV && mix do ecto.create, ecto.migrate"
migrate: build postgres
@$(MAKE) -f $(THIS_FILE) migrate_only
@ -437,7 +441,7 @@ start: build postgres
@docker run --rm --name $(BS_CONTAINER_NAME) \
$(BLOCKSCOUT_CONTAINER_PARAMS) \
-p 4000:4000 \
$(DOCKER_IMAGE) /bin/sh -c "mix phx.server"
$(BS_CONTAINER_IMAGE) /bin/sh -c "mix phx.server"
BS_STARTED := $(shell docker ps --filter name=${BS_CONTAINER_NAME} | grep ${BS_CONTAINER_NAME})
stop:
@ -458,9 +462,46 @@ endif
run: start
docker-login: ## login to DockerHub with credentials found in env
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
# Docker release - build, tag and push the container
release: build publish ## Make a release by building and publishing the `{version}` ans `latest` tagged containers to hub
# Docker publish
publish: docker-login publish-latest publish-version ## publish the `{version}` ans `latest` tagged containers to hub
publish-latest: tag-latest ## publish the `latest` tagged container to hub
@echo 'publish latest to $(DOCKER_REPO)'
docker push $(DOCKER_REPO)/$(APP_NAME):latest
publish-version: tag-version ## publish the `{version}` tagged container to hub
@echo 'publish $(TAG) to $(DOCKER_REPO)'
docker push $(DOCKER_REPO)/$(APP_NAME):$(TAG)
# Docker tagging
tag: tag-latest tag-version ## Generate container tags for the `{version}` ans `latest` tags
tag-latest: ## Generate container `latest` tag
@echo 'create latest tag'
docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):latest
tag-version: ## Generate container `{version}` tag
@echo 'create tag $(TAG)'
docker tag $(APP_NAME) $(DOCKER_REPO)/$(APP_NAME):$(TAG)
.PHONY: build \
migrate \
start \
stop \
postgres \
run
run \
docker-login \
release \
publish \
publish-latest \
publish-version \
tag \
tag-latest \
tag-version

Loading…
Cancel
Save