<commit_before># Default variables
DOCKER_NAMESPACE ?=	armbuild/
DISK ?=			/dev/nbd1
S3_URL ?=		s3://test-images
IS_LATEST ?=		0
BUILDDIR ?=		/tmp/build/$(NAME)-$(VERSION)/
SOURCE_URL ?=		https://github.com/online-labs/image-builder
DOC_URL ?=		https://doc.cloud.online.net
HELP_URL ?=		https://community.cloud.online.net
TITLE ?=		$(NAME)
DESCRIPTION ?=		$(TITLE)

# Phonies
.PHONY: build release install install_on_disk publish_on_s3 clean shell re all run
.PHONY: publish_on_s3.tar publish_on_s3.sqsh publish_on_s3.tar.gz travis


# Default action
all: build


# Actions
build: .docker-container.built


release: build
	docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):$(VERSION)
	docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):$(shell date +%Y-%m-%d)
	docker push $(DOCKER_NAMESPACE)$(NAME):$(VERSION)
	docker push $(DOCKER_NAMESPACE)$(NAME):$(shell date +%Y-%m-%d)
	if [ "x$(IS_LATEST)" = "x1" ]; then \
	    docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):latest; \
	    docker push $(DOCKER_NAMESPACE)$(NAME):latest; \
	fi


install_on_disk: /mnt/$(DISK)
	tar -C /mnt/$(DISK) -xf $(BUILDDIR)rootfs.tar


publish_on_s3.tar: $(BUILDDIR)rootfs.tar
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).tar


publish_on_s3.tar.gz: $(BUILDDIR)rootfs.tar.gz
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).tar.gz


publish_on_s3.sqsh: $(BUILDDIR)rootfs.sqsh
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).sqsh


fclean: clean
	-docker rmi $(NAME):$(VERSION) || true


clean:
	-rm -f $(BUILDDIR)rootfs.tar $(BUILDDIR)export.tar .??*.built
	-rm -rf $(BUILDDIR)rootfs


shell:  .docker-container.built
	docker run --rm -it $(NAME):$(VERSION) /bin/bash

test:  .docker-container.built
	docker run --rm -it -e SKIP_NON_DOCKER=1 $(NAME):$(VERSION) /bin/bash -c 'SCRIPT=$$(mktemp); curl -s https://raw.githubusercontent.com/online-labs/image-tools/master/unit.bash > $$SCRIPT; bash $$SCRIPT'

travis:
	find . -name Dockerfile | xargs cat | grep -vi ^maintainer | bash -n

# Aliases
publish_on_s3: publish_on_s3.tar
install: install_on_disk
run: shell<commit_msg>Made SHELL overridable<commit_after># Default variables
DOCKER_NAMESPACE ?=	armbuild/
DISK ?=			/dev/nbd1
S3_URL ?=		s3://test-images
IS_LATEST ?=		0
BUILDDIR ?=		/tmp/build/$(NAME)-$(VERSION)/
SOURCE_URL ?=		https://github.com/online-labs/image-builder
DOC_URL ?=		https://doc.cloud.online.net
HELP_URL ?=		https://community.cloud.online.net
TITLE ?=		$(NAME)
DESCRIPTION ?=		$(TITLE)
SHELL ?=		/bin/bash

# Phonies
.PHONY: build release install install_on_disk publish_on_s3 clean shell re all run
.PHONY: publish_on_s3.tar publish_on_s3.sqsh publish_on_s3.tar.gz travis


# Default action
all: build


# Actions
build: .docker-container.built


release: build
	docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):$(VERSION)
	docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):$(shell date +%Y-%m-%d)
	docker push $(DOCKER_NAMESPACE)$(NAME):$(VERSION)
	docker push $(DOCKER_NAMESPACE)$(NAME):$(shell date +%Y-%m-%d)
	if [ "x$(IS_LATEST)" = "x1" ]; then \
	    docker tag  $(NAME):$(VERSION) $(DOCKER_NAMESPACE)$(NAME):latest; \
	    docker push $(DOCKER_NAMESPACE)$(NAME):latest; \
	fi


install_on_disk: /mnt/$(DISK)
	tar -C /mnt/$(DISK) -xf $(BUILDDIR)rootfs.tar


publish_on_s3.tar: $(BUILDDIR)rootfs.tar
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).tar


publish_on_s3.tar.gz: $(BUILDDIR)rootfs.tar.gz
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).tar.gz


publish_on_s3.sqsh: $(BUILDDIR)rootfs.sqsh
	s3cmd put --acl-public $< $(S3_URL)/$(NAME)-$(VERSION).sqsh


fclean: clean
	-docker rmi $(NAME):$(VERSION) || true


clean:
	-rm -f $(BUILDDIR)rootfs.tar $(BUILDDIR)export.tar .??*.built
	-rm -rf $(BUILDDIR)rootfs


shell:  .docker-container.built
	docker run --rm -it $(NAME):$(VERSION) $(SHELL)

test:  .docker-container.built
	docker run --rm -it -e SKIP_NON_DOCKER=1 $(NAME):$(VERSION) $(SHELL) -c 'SCRIPT=$$(mktemp); curl -s https://raw.githubusercontent.com/online-labs/image-tools/master/unit.bash > $$SCRIPT; bash $$SCRIPT'

travis:
	find . -name Dockerfile | xargs cat | grep -vi ^maintainer | bash -n

# Aliases
publish_on_s3: publish_on_s3.tar
install: install_on_disk
run: shell
{'fraction_non_alphanumeric': 0.18314845409487845, 'fraction_numerical': 0.009912674061836204, 'mean_word_length': 4.568988173455979, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, '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': '713674', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1741, 'n_words': 329}