forked from open-horizon-services/web-helloworld-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 1.75 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
# Extremely simple HTTP server that responds on port 8000 with a hello message.
DOCKER_HUB_ID ?= ibmosquito
SERVICE_NAME ?= web-hello-python
SERVICE_VERSION ?= 1.0.0
PATTERN_NAME ?= pattern-web-hello-python
ARCH ?= amd64
# Leave blank for open DockerHub containers
# CONTAINER_CREDS:=-r "registry.wherever.com:myid:mypw"
CONTAINER_CREDS ?=
default: build run
build:
docker build -t $(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION) .
dev: stop build
docker run -it -v `pwd`:/outside \
--name ${SERVICE_NAME} \
-p 8000:8000 \
$(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION) /bin/bash
run: stop
docker run -d \
--name ${SERVICE_NAME} \
--restart unless-stopped \
-p 8000:8000 \
$(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION)
test:
@curl -sS http://127.0.0.1:8000
push:
docker push $(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION)
publish-service:
@ARCH=$(ARCH) \
SERVICE_NAME="$(SERVICE_NAME)" \
SERVICE_VERSION="$(SERVICE_VERSION)"\
SERVICE_CONTAINER="$(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION)" \
hzn exchange service publish -O $(CONTAINER_CREDS) -f service.json --pull-image
publish-pattern:
@ARCH=$(ARCH) \
SERVICE_NAME="$(SERVICE_NAME)" \
SERVICE_VERSION="$(SERVICE_VERSION)"\
PATTERN_NAME="$(PATTERN_NAME)" \
hzn exchange pattern publish -f pattern.json
stop:
@docker rm -f ${SERVICE_NAME} >/dev/null 2>&1 || :
clean:
@docker rmi -f $(DOCKER_HUB_ID)/$(SERVICE_NAME):$(SERVICE_VERSION) >/dev/null 2>&1 || :
agent-run: agent-stop
@hzn register --pattern "${HZN_ORG_ID}/$(PATTERN_NAME)"
agent-stop:
@hzn unregister -f
.PHONY: build dev run push publish-service publish-pattern test stop clean agent-run agent-stop