-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
266 lines (237 loc) · 8.66 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
SHELL := /bin/bash
.PHONY: \
init_yarn \
init_go \
init_shfmt \
init_shellcheck \
init_docker \
init_docker_compose \
init_hadolint \
init_helm \
init_chart_releaser \
init_all \
format_all \
lint_all \
prepare_saleor_sources \
build_saleor_core \
build_saleor_core_dev \
build_saleor_dashboard \
build_saleor_storefront \
push_saleor_core \
push_saleor_core_dev \
push_saleor_dashboard \
push_saleor_storefront \
get_image \
get_image_version \
push_image \
push_updated_charts
## Dependency installation targets
init_yarn:
if [ -z "$$(command -v yarn)" ]; then ./scripts/make.sh install_yarn; fi
if [ -z "$$(command -v ./node_modules/.bin/prettier)" ]; then ./scripts/make.sh install_yarn; fi
if [ -z "$$(command -v ./node_modules/.bin/markdownlint)" ]; then ./scripts/make.sh install_yarn; fi
init_go:
if [[ -z "$$(command -v go)" ]]; then ./scripts/make.sh install_golang "${GO_LANG_VERSION}"; fi
init_shfmt:
if [ -z "$$(command -v shfmt)" ]; then ./scripts/make.sh install_shfmt "${SHFMT_VERSION}"; fi
init_shellcheck:
if [ -z "$$(command -v shellcheck)" ]; then ./scripts/make.sh install_shellcheck "${SHELLCHECK_VERSION}"; fi
init_docker:
if [ -z "$$(command -v docker)" ]; then ./scripts/make.sh install_docker "${DOCKER_VERSION}"; fi
if [[ ! "$$(docker version | awk NR==2)" =~ "${DOCKER_VERSION}" ]]; then \
./scripts/make.sh install_docker "${DOCKER_VERSION}"; \
fi
init_docker_compose:
if [ -z "$$(command -v docker)" ]; then ./scripts/make.sh install_docker_compose "${DOCKER_COMPOSE_VERSION}"; fi
if [[ -z "$$(command -v docker-compose)" ]]; then ./scripts/make.sh install_docker_compose "${DOCKER_COMPOSE_VERSION}"; fi
init_helm:
if [ -z "$$(command -v helm)" ]; then ./scripts/make.sh install_helm_client "${HELM_VERSION}"; fi
init_hadolint:
if [ -z "$$(command -v install_hadolint)" ]; then ./scripts/make.sh install_hadolint "${HADOLINT_VERSION}"; fi
init_chart_releaser:
if [ -z "$$(command -v cr)" ]; then ./scripts/make.sh install_helm_chart_releaser "${CHART_RELEASER_VERSION}"; fi
init_all: \
init_yarn \
init_go \
init_shfmt \
init_shellcheck \
init_docker \
init_docker_compose \
init_helm \
init_hadolint \
init_chart_releaser
## Code consistency/quality targets
format_all: init_all
./scripts/make.sh format_yaml
./scripts/make.sh format_shell
./scripts/make.sh format_markdown
lint_all: init_all
./scripts/make.sh lint_yaml
./scripts/make.sh lint_shell
./scripts/make.sh lint_markdown
./scripts/make.sh lint_dockerfiles
get_image:
@if test -z "$(FILTER)"; then \
echo "env variable FILTER is required" && \
exit 1; \
fi;
@./scripts/make.sh get_image "${FILTER}"
unset FILTER
get_image_version:
@if test -z "$(SALEOR_REPO)"; then \
echo "env variable SALEOR_REPO is required" && \
exit 1; \
fi;
@./scripts/make.sh get_image_version "${SALEOR_REPO}"
unset SALEOR_REPO
push_image:
@if test -z "$(IMAGE_VERSION)"; then \
echo "env variable IMAGE_VERSION is required" && \
exit 1; \
fi;
@if test -z "$(DOCKER_REPO)"; then \
echo "env variable DOCKER_REPO is required" && \
exit 1; \
fi;
@./scripts/make.sh push_image "${IMAGE_VERSION}" "${DOCKER_REPO}" "${FORCE_PUSH}"
unset IMAGE_VERSION
unset DOCKER_REPO
prepare_saleor_sources:
./scripts/make.sh prepare_saleor_source \
"https://github.com/mirumee/saleor.git" \
"Core.Dockerfile" && \
./scripts/make.sh prepare_saleor_source \
"https://github.com/mirumee/saleor.git" \
"Core.Dev.Dockerfile" && \
./scripts/make.sh prepare_saleor_source \
"https://github.com/mirumee/saleor-dashboard.git" \
"Dashboard.Dockerfile" && \
./scripts/make.sh prepare_saleor_source \
"https://github.com/mirumee/saleor-storefront.git" \
"Storefront.Dockerfile"
build_saleor_core: prepare_saleor_sources
./scripts/make.sh set_env_saleor_core
docker-compose build saleor_core
docker image ls
make -s get_image FILTER=saleor_core
docker run \
--rm "$$(make -s get_image FILTER=saleor_core)" \
/bin/bash -c 'echo "build ok"' || \
(echo "docker image is broken"; exit 1;)
docker image inspect \
"$$(make -s get_image FILTER=saleor_core)"
rm .env
build_saleor_core_dev: prepare_saleor_sources
./scripts/make.sh set_env_saleor_core_dev
docker-compose build saleor_core_dev
docker image ls
make -s get_image FILTER=saleor_core_dev
docker run \
--rm "$$(make -s get_image FILTER=saleor_core_dev)" \
/bin/bash -c 'echo "build ok"' || \
(echo "docker image is broken"; exit 1;)
docker image inspect \
"$$(make -s get_image FILTER=saleor_core_dev)"
rm .env
build_saleor_dashboard: prepare_saleor_sources
./scripts/make.sh set_env_saleor_dashboard
docker-compose build saleor_dashboard
docker image ls
make -s get_image FILTER=saleor_dashboard
docker run \
--rm "$$(make -s get_image FILTER=saleor_dashboard)" \
/bin/bash -c 'echo "build ok"' || \
(echo "docker image is broken"; exit 1;)
docker image inspect \
"$$(make -s get_image FILTER=saleor_dashboard)"
rm .env
build_saleor_storefront: prepare_saleor_sources
./scripts/make.sh set_env_saleor_storefront
docker-compose build saleor_storefront
docker image ls
make -s get_image FILTER=saleor_storefront
docker run \
--rm "$$(make -s get_image FILTER=saleor_storefront)" \
/bin/bash -c 'echo "build ok"' || \
(echo "docker image is broken"; exit 1;)
docker image inspect \
"$$(make -s get_image FILTER=saleor_storefront)"
rm .env
push_saleor_core:
@if test -z "$(REGISTRY_TOKEN)"; then \
echo "env variable REGISTRY_TOKEN is required" && \
exit 1; \
fi;
docker tag \
"$$(make -s get_image FILTER=saleor_core)" \
"ghcr.io/eirenauts/saleor-core:$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)"
docker tag \
"$$(make -s get_image FILTER=saleor_core)" \
"ghcr.io/eirenauts/saleor-core:latest"
echo "${REGISTRY_TOKEN}" | docker login ghcr.io -u eirenauts --password-stdin
make -s push_image \
IMAGE_VERSION="$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)" \
DOCKER_REPO=saleor-core \
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
if [[ -e /home/vsts/.docker/config.json ]]; then rm /home/vsts/.docker/config.json; fi
push_saleor_core_dev:
@if test -z "$(REGISTRY_TOKEN)"; then \
echo "env variable REGISTRY_TOKEN is required" && \
exit 1; \
fi;
docker tag \
"$$(make -s get_image FILTER=saleor_core_dev)" \
"ghcr.io/eirenauts/saleor-core:dev-$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)"
docker tag \
"$$(make -s get_image FILTER=saleor_core_dev)" \
"ghcr.io/eirenauts/saleor-core:dev-latest"
echo "${REGISTRY_TOKEN}" | docker login ghcr.io -u eirenauts --password-stdin
make -s push_image \
IMAGE_VERSION="dev-$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)" \
DOCKER_REPO=saleor-core \
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
if [[ -e /home/vsts/.docker/config.json ]]; then rm /home/vsts/.docker/config.json; fi
push_saleor_dashboard:
@if test -z "$(REGISTRY_TOKEN)"; then \
echo "env variable REGISTRY_TOKEN is required" && \
exit 1; \
fi;
docker tag \
"$$(make -s get_image FILTER=saleor_dashboard)" \
"ghcr.io/eirenauts/saleor-dashboard:$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor-dashboard.git)"
docker tag \
"$$(make -s get_image FILTER=saleor_dashboard)" \
"ghcr.io/eirenauts/saleor-dashboard:latest"
echo "${REGISTRY_TOKEN}" | docker login ghcr.io -u eirenauts --password-stdin
make -s push_image \
IMAGE_VERSION="$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor-dashboard.git)" \
DOCKER_REPO=saleor-dashboard \
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
if [[ -e /home/vsts/.docker/config.json ]]; then rm /home/vsts/.docker/config.json; fi
push_saleor_storefront:
@if test -z "$(REGISTRY_TOKEN)"; then \
echo "env variable REGISTRY_TOKEN is required" && \
exit 1; \
fi;
docker tag \
"$$(make -s get_image FILTER=saleor_storefront)" \
"ghcr.io/eirenauts/saleor-storefront:$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor-storefront.git)"
docker tag \
"$$(make -s get_image FILTER=saleor_storefront)" \
"ghcr.io/eirenauts/saleor-storefront:latest"
echo "${REGISTRY_TOKEN}" | docker login ghcr.io -u eirenauts --password-stdin
make -s push_image \
IMAGE_VERSION="$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor-storefront.git)" \
DOCKER_REPO=saleor-storefront \
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
if [[ -e /home/vsts/.docker/config.json ]]; then rm /home/vsts/.docker/config.json; fi
push_updated_charts:
@if test -z "$(CR_TOKEN)"; then \
echo "env variable CR_TOKEN is required" && \
exit 1; \
fi;
./scripts/make.sh package_newly_versioned_charts "${CR_TOKEN}"