caiok commented on a change in pull request #197: BOOKKEEPER-974: Add an official bookkeeper docker image URL: https://github.com/apache/bookkeeper/pull/197#discussion_r127252807
########## File path: docker/Makefile ########## @@ -0,0 +1,180 @@ + +VERSION ?= 4.4.0-alpine +IMAGE ?= caiok/bookkeeper:$(VERSION) +BOOKIE ?= 1 +DOCKER_NETWORK ?= bk_network + +BUILD_DIR ?= $(VERSION) + +CONTAINER_NAME = bookkeeper-$(BOOKIE) +DOCKER_HOSTNAME = $(shell hostname) +BK_LOCAL_DATA_DIR = /tmp/test_bk +BK_LOCAL_CONTAINER_DATA_DIR = $(BK_LOCAL_DATA_DIR)/$(CONTAINER_NAME) + +ZK_CONTAINER_NAME=test_zookeeper +ZK_LOCAL_DATA_DIR=$(BK_LOCAL_DATA_DIR)/zookkeeper + +CONTAINER_IP=$(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(CONTAINER_NAME)) + +#NOCACHE=--no-cache +NOCACHE= + +# -------------------------------- # + +.PHONY: all build run create start stop shell exec root-shell root-exec info ip clean-files clean + +# -------------------------------- # + +all: + make info + +# -------------------------------- # + +# Build the bookkeeper image. +# make build + +build: + #-docker rmi -f $(IMAGE) + + cd $(BUILD_DIR) ; \ + time docker build \ + $(NOCACHE) \ + -t $(IMAGE) . + +# -------------------------------- # + +# Create and run a bookkeeper container with data persisted on local filesystem. It needs the zookkeeper container. +# In order to launch several bookies, the command need the bookie number +# make run-bk BOOKIE=4 + +run-bk: + # Temporary gimmick: clear all data because of bookkeeper blocking check on host / data integrity + #-sudo rm -rf $(BK_LOCAL_CONTAINER_DATA_DIR) + + mkdir -p $(BK_LOCAL_DATA_DIR) \ + $(BK_LOCAL_CONTAINER_DATA_DIR) \ + $(BK_LOCAL_CONTAINER_DATA_DIR)/journal \ + $(BK_LOCAL_CONTAINER_DATA_DIR)/ledger \ + $(BK_LOCAL_CONTAINER_DATA_DIR)/index + + -docker rm -f $(CONTAINER_NAME) + docker run -it\ + --network $(DOCKER_NETWORK) \ + --volume $(BK_LOCAL_CONTAINER_DATA_DIR)/journal:/data/journal \ + --volume $(BK_LOCAL_CONTAINER_DATA_DIR)/ledger:/data/ledger \ + --volume $(BK_LOCAL_CONTAINER_DATA_DIR)/index:/data/index \ + --name "$(CONTAINER_NAME)" \ + --hostname "$(CONTAINER_NAME)" \ + --env ZK_SERVERS=$(ZK_CONTAINER_NAME):2181 \ + $(IMAGE) + +# -------------------------------- # + +# Create run and destroy a container that will format zookkeeper metadata +# make run-format + +run-format: + docker run -it --rm \ + --network $(DOCKER_NETWORK) \ + --env ZK_SERVERS=$(ZK_CONTAINER_NAME):2181 \ + $(IMAGE) \ + bookkeeper shell metaformat $(FORMAT_OPTS) + +# -------------------------------- # + +# Create and run the zookkeeper container needed by the ensemble +# make run-zk + +run-zk: + -docker network create $(DOCKER_NETWORK) + mkdir -pv $(BK_LOCAL_DATA_DIR) $(ZK_LOCAL_DATA_DIR) $(ZK_LOCAL_DATA_DIR)/data $(ZK_LOCAL_DATA_DIR)/datalog + -docker rm -f $(ZK_CONTAINER_NAME) + docker run -it --rm \ + --network $(DOCKER_NETWORK) \ + --name "$(ZK_CONTAINER_NAME)" \ + --hostname "$(ZK_CONTAINER_NAME)" \ + -v $(ZK_LOCAL_DATA_DIR)/data:/data \ + -v $(ZK_LOCAL_DATA_DIR)/datalog:/datalog \ + -p 2181:2181 \ + zookeeper + +# -------------------------------- # + +# Create and run a container running the bookkeeper tutorial application (a simple dice rolling application). It's possibile +# to run several dice applications in order to simulate a real life concurrent scenario. +# make run-dice +run-dice: Review comment: Are you saying to bring the tutorial code in bk repo and have a docker build for that image? I think it could be a good idea (so the code will be updated with releases), but it need a general consensus. @sijie @jvrao @jiazhai @eolivelli what do you think about it? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services