-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
115 lines (94 loc) · 3.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# execute these tasks when `make` with no target is invoked
default: up
# import environment file for setting or overriding
# configuration used by this Makefile
include .env
# source all variables in environment file
# This only runs in the make command shell
# so won't affect your login shell
export $(shell sed 's/=.*//' .env)
.PHONY: vendor-blockscout
# download blockscout sources locally for building
# custom versions of blockscout
vendor-blockscout:
git submodule update --init --recursive
.PHONY: build
# build a development version docker image of the service
build:
cd blockscout && \
docker build ./ -f Dockerfile -t ${IMAGE_NAME}:${LOCAL_IMAGE_TAG} --build-arg BLOCKSCOUT_VERSION=${BLOCKSCOUT_DOCKER_VERSION}
local:
cd blockscout && \
docker build ./ -f local.Dockerfile -t ${IMAGE_NAME}:${LOCAL_IMAGE_TAG} --build-arg BLOCKSCOUT_VERSION=${BLOCKSCOUT_DOCKER_VERSION}
.PHONY: build-db-exporter
# build the exporter image
build-db-exporter:
cd db_exporter && \
docker build ./ -t blockscout-db-exporter
.PHONY: build-db-importer
# build the importer image
build-db-importer:
cd db_importer && \
docker buildx bake -f docker-bake.hcl --load
.PHONY: publish
# build a production version docker image of the service
publish:
cd blockscout && \
docker build ./ -f Dockerfile -t ${IMAGE_NAME}:${PRODUCTION_IMAGE_TAG}
.PHONY: hotfix-release
# build a production image using local sources and push it to the remote repository using tag `hotfix
hotfix-release: publish
AWS_PROFILE=shared aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 843137275421.dkr.ecr.us-east-1.amazonaws.com && \
docker tag ${IMAGE_NAME}:${PRODUCTION_IMAGE_TAG} 843137275421.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:hotfix && \
docker push 843137275421.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:hotfix
.PHONY: release
# build and push an image using local sources and tagged according to values
# specified in /.env
release: publish
AWS_PROFILE=shared aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 843137275421.dkr.ecr.us-east-1.amazonaws.com && \
docker tag ${IMAGE_NAME}:${PRODUCTION_IMAGE_TAG} 843137275421.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${PRODUCTION_IMAGE_TAG} && \
docker push 843137275421.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${PRODUCTION_IMAGE_TAG}
.PHONY: up
# start dockerized versions of the service and it's dependencies
up:
docker compose up -d
.PHONY: down
# stop the service and it's dependencies
down:
docker compose down
.PHONY: restart
# restart just the service (useful for picking up new environment variable values)
restart:
docker compose up -d blockscout --force-recreate
.PHONY: restart-postgres
# restart just the database without wiping it's data
restart-postgres:
docker compose up -d postgres --force-recreate
.PHONY: reset
# wipe state and restart the service and all it's dependencies
reset:
rm -rf postgres-data && \
docker compose up -d --build --remove-orphans --renew-anon-volumes --force-recreate
# wipe just the database state and restart just the database
.PHONY: reset-postgres
reset-postgres:
docker compose stop postgres && \
rm -rf postgres-data && \
docker compose up -d postgres --force-recreate --renew-anon-volumes
.PHONY: refresh
# rebuild from latest local sources and restart just the service containers
# (preserving any volume state such as database tables & rows)
refresh:
docker compose up -d blockscout --build --force-recreate
.PHONY: logs
# follow the logs from all the dockerized services
# make logs
# or one
# make logs S=blockscout
logs:
docker compose logs ${S} -f
.PHONY: debug-database
# open a connection to the postgres database for debugging it's state
# https://www.postgresql.org/docs/current/app-psql.html
debug-database:
docker compose exec postgres psql -U ${POSTGRES_ADMIN_USERNAME} -d ${POSTGRES_BLOCKSCOUT_DATABASE_NAME}