2019-03-14 16:31:57 +00:00
|
|
|
SERVICE_NAME := service-erlang
|
|
|
|
BASE_IMAGE_NAME := embedded-base
|
2019-03-21 10:28:03 +00:00
|
|
|
BASE_IMAGE_TAG := 5b03665c38aa0b003306fd6981cfda005de9c444
|
2019-03-20 10:42:28 +00:00
|
|
|
|
|
|
|
REGISTRY ?= dr2.rbkmoney.com
|
2019-03-14 16:31:57 +00:00
|
|
|
|
2016-10-05 16:39:48 +00:00
|
|
|
UTILS_PATH := build_utils
|
|
|
|
|
2019-03-14 16:31:57 +00:00
|
|
|
.PHONY: $(SERVICE_NAME) push clean
|
|
|
|
$(SERVICE_NAME): .image-tag
|
|
|
|
|
|
|
|
COMMIT := $(shell git rev-parse HEAD)
|
|
|
|
rev = $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
BRANCH := $(shell \
|
|
|
|
if [[ "${rev}" != "HEAD" ]]; then \
|
|
|
|
echo "${rev}" ; \
|
|
|
|
elif [ -n "${BRANCH_NAME}" ]; then \
|
|
|
|
echo "${BRANCH_NAME}"; \
|
|
|
|
else \
|
|
|
|
echo `git name-rev --name-only HEAD`; \
|
|
|
|
fi)
|
|
|
|
SERVICE_IMAGE_TAG=$(COMMIT)
|
|
|
|
-include $(UTILS_PATH)/make_lib/utils_repo.mk
|
2016-10-05 16:39:48 +00:00
|
|
|
|
|
|
|
|
2019-03-14 16:31:57 +00:00
|
|
|
SUBMODULES := $(UTILS_PATH)
|
|
|
|
SUBTARGETS := $(patsubst %,%/.git,$(SUBMODULES))
|
2016-10-05 16:39:48 +00:00
|
|
|
|
2019-03-14 16:31:57 +00:00
|
|
|
$(SUBTARGETS):
|
|
|
|
$(eval SSH_PRIVKEY := $(shell echo $(GITHUB_PRIVKEY) | sed -e 's|%|%%|g'))
|
|
|
|
GIT_SSH_COMMAND="$(shell which ssh) -o StrictHostKeyChecking=no -o User=git `[ -n '$(SSH_PRIVKEY)' ] && echo -o IdentityFile='$(SSH_PRIVKEY)'`" \
|
|
|
|
git submodule update --init $(basename $@)
|
2016-10-05 16:39:48 +00:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
submodules: $(SUBTARGETS)
|
|
|
|
|
2019-03-14 16:31:57 +00:00
|
|
|
Dockerfile: Dockerfile.sh
|
|
|
|
REGISTRY=$(REGISTRY) ORG_NAME=$(ORG_NAME) \
|
|
|
|
BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
|
2019-03-20 10:42:28 +00:00
|
|
|
BUILD_IMAGE_NAME=$(BUILD_IMAGE_NAME) BUILD_IMAGE_TAG=$(BUILD_IMAGE_TAG) \
|
2019-03-14 16:31:57 +00:00
|
|
|
COMMIT=$(COMMIT) BRANCH=$(BRANCH) \
|
|
|
|
./Dockerfile.sh > Dockerfile
|
|
|
|
|
|
|
|
.image-tag: Dockerfile
|
|
|
|
docker build -t "$(SERVICE_IMAGE_NAME):$(COMMIT)" .
|
|
|
|
echo $(COMMIT) > $@
|
|
|
|
|
|
|
|
push:
|
|
|
|
if [ -f .image-tag ]; then $(DOCKER) push "$(SERVICE_IMAGE_NAME):`cat .image-tag`"; \
|
|
|
|
else echo "No .image-tag file. Build the image first"; exit 1; fi
|
|
|
|
|
2016-10-05 16:39:48 +00:00
|
|
|
clean:
|
2019-03-14 16:31:57 +00:00
|
|
|
if [ -f .image-tag ]; then $(DOCKER) rmi -f "$(SERVICE_IMAGE_NAME):`cat .image-tag`"; fi
|
|
|
|
rm -f .image-tag Dockerfile
|