<commit_before># Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include ../image.mk

# ====================================================================================
# Image Build Options

ROOKD_IMAGE = $(BUILD_REGISTRY)/rook-$(GOARCH)
ROOKD_BASE_IMAGE = $(BUILD_REGISTRY)/rook-base-$(GOARCH)
IMAGES = $(ROOKD_IMAGE) $(ROOKD_BASE_IMAGE)
CACHE_IMAGES = $(ROOKD_BASE_IMAGE)

BASEIMAGE = $(BUILD_REGISTRY)/base-$(GOARCH)

TEMP := $(shell mktemp -d)

# ====================================================================================
# Build Ceph

CEPH_BUILD_TYPE ?= release
CEPH_ALLOCATOR ?= tcmalloc

ifeq ($(CEPH_ALLOCATOR),tcmalloc)
EXTRA_LIBS += libgoogle-perftools4
endif
ifeq ($(CEPH_ALLOCATOR),tcmalloc_minimal)
EXTRA_LIBS += libtcmalloc_minimal4
endif
ifeq ($(CEPH_ALLOCATOR),jemalloc)
EXTRA_LIBS += libjemalloc1
endif

CEPH_TARBALL_FILENAME = ceph-install.tar
CEPH_TARBALL = $(TEMP)/$(CEPH_TARBALL_FILENAME)

$(CEPH_TARBALL):
	@echo === building ceph for $(ROOKD_IMAGE)
	@$(MAKE) -C ../ceph GOARCH=$(GOARCH) CEPH_ALLOCATOR=$(CEPH_ALLOCATOR) CEPH_BUILD_TYPE=$(CEPH_BUILD_TYPE) $(CEPH_TARBALL)

# ====================================================================================
# Build Rook

rook-base-image: $(CEPH_TARBALL)
	@echo === docker build $(ROOKD_BASE_IMAGE)
	@cp Dockerfile.base $(TEMP)/Dockerfile
	@cd $(TEMP) && $(SED_CMD) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
	@docker build $(BUILD_ARGS) --build-arg EXTRALIBS=$(EXTRA_LIBS) -t $(ROOKD_BASE_IMAGE) $(TEMP)

# since this is a leaf image we avoid leaving around a lot of dangling images
# by removing the last build of the final rook image
OLD_IMAGE_ID := $(shell docker images -q $(ROOKD_IMAGE))
CURRENT_IMAGE_ID := $$(docker images -q $(ROOKD_IMAGE))

do.build: rook-base-image
	@echo === docker build $(ROOKD_IMAGE)
	@cp Dockerfile $(TEMP)
	@cp $(OUTPUT_DIR)/linux_$(GOARCH)/rook $(TEMP)
	@cd $(TEMP) && $(SED_CMD) 's|BASEIMAGE|$(ROOKD_BASE_IMAGE)|g' Dockerfile
	@docker build $(BUILD_ARGS) -t $(ROOKD_IMAGE) $(TEMP)
	@[ "$(OLD_IMAGE_ID)" != "$(CURRENT_IMAGE_ID)" ] && [ -n "$(OLD_IMAGE_ID)" ] && docker rmi $(OLD_IMAGE_ID) || true
	@rm -fr $(TEMP)
<commit_msg>ceph: use libc allocator on non intel platforms<commit_after># Copyright 2016 The Rook Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include ../image.mk

# ====================================================================================
# Image Build Options

ROOKD_IMAGE = $(BUILD_REGISTRY)/rook-$(GOARCH)
ROOKD_BASE_IMAGE = $(BUILD_REGISTRY)/rook-base-$(GOARCH)
IMAGES = $(ROOKD_IMAGE) $(ROOKD_BASE_IMAGE)
CACHE_IMAGES = $(ROOKD_BASE_IMAGE)

BASEIMAGE = $(BUILD_REGISTRY)/base-$(GOARCH)

TEMP := $(shell mktemp -d)

# ====================================================================================
# Build Ceph

CEPH_BUILD_TYPE ?= release

ifeq ($(GOARCH),amd64)
CEPH_ALLOCATOR ?= tcmalloc
else
CEPH_ALLOCATOR ?= libc
endif

ifeq ($(CEPH_ALLOCATOR),tcmalloc)
EXTRA_LIBS += libgoogle-perftools4
endif
ifeq ($(CEPH_ALLOCATOR),tcmalloc_minimal)
EXTRA_LIBS += libtcmalloc_minimal4
endif
ifeq ($(CEPH_ALLOCATOR),jemalloc)
EXTRA_LIBS += libjemalloc1
endif

CEPH_TARBALL_FILENAME = ceph-install.tar
CEPH_TARBALL = $(TEMP)/$(CEPH_TARBALL_FILENAME)

$(CEPH_TARBALL):
	@echo === building ceph for $(ROOKD_IMAGE)
	@$(MAKE) -C ../ceph GOARCH=$(GOARCH) CEPH_ALLOCATOR=$(CEPH_ALLOCATOR) CEPH_BUILD_TYPE=$(CEPH_BUILD_TYPE) $(CEPH_TARBALL)

# ====================================================================================
# Build Rook

rook-base-image: $(CEPH_TARBALL)
	@echo === docker build $(ROOKD_BASE_IMAGE)
	@cp Dockerfile.base $(TEMP)/Dockerfile
	@cd $(TEMP) && $(SED_CMD) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
	@docker build $(BUILD_ARGS) --build-arg EXTRALIBS=$(EXTRA_LIBS) -t $(ROOKD_BASE_IMAGE) $(TEMP)

# since this is a leaf image we avoid leaving around a lot of dangling images
# by removing the last build of the final rook image
OLD_IMAGE_ID := $(shell docker images -q $(ROOKD_IMAGE))
CURRENT_IMAGE_ID := $$(docker images -q $(ROOKD_IMAGE))

do.build: rook-base-image
	@echo === docker build $(ROOKD_IMAGE)
	@cp Dockerfile $(TEMP)
	@cp $(OUTPUT_DIR)/linux_$(GOARCH)/rook $(TEMP)
	@cd $(TEMP) && $(SED_CMD) 's|BASEIMAGE|$(ROOKD_BASE_IMAGE)|g' Dockerfile
	@docker build $(BUILD_ARGS) -t $(ROOKD_IMAGE) $(TEMP)
	@[ "$(OLD_IMAGE_ID)" != "$(CURRENT_IMAGE_ID)" ] && [ -n "$(OLD_IMAGE_ID)" ] && docker rmi $(OLD_IMAGE_ID) || true
	@rm -fr $(TEMP)

{'fraction_non_alphanumeric': 0.21649672250546248, 'fraction_numerical': 0.004369992716678805, 'mean_word_length': 6.208661417322834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6846255', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1818, 'n_words': 491}