diff --git a/Makefile b/Makefile index e1446a1..efbdc4d 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,11 @@ lint: generate $(MAKE) -C build/$$version lint; \ done +snapshot: generate build + for version in $(VERSIONS); do \ + $(MAKE) -C build/$$version snapshot; \ + done + tag: generate for version in $(VERSIONS); do \ $(MAKE) -C build/$$version tag; \ diff --git a/templates/Makefile b/templates/Makefile index 8f0925d..83c6bba 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -9,20 +9,31 @@ GIT_TAG=$(QNAME):$(VCS_REF) BUILD_TAG=$(QNAME):$(IMAGE_VERSION) LATEST_TAG=$(QNAME):latest +SNAPSHOT_IMAGE_NAME=docker-emulator-snapshot-{{ platform }} +SNAPSHOT_QNAME=$(PROXY)$(OWNER)/$(SNAPSHOT_IMAGE_NAME) +SNAPSHOT_GIT_TAG=$(SNAPSHOT_QNAME):$(VCS_REF) +SNAPSHOT_BUILD_TAG=$(SNAPSHOT_QNAME):$(IMAGE_VERSION) +SNAPSHOT_LATEST_TAG=$(SNAPSHOT_QNAME):latest + ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) build: docker build \ --build-arg VCS_REF=$(VCS_REF) \ --build-arg IMAGE_VERSION=$(IMAGE_VERSION) \ - -t $(GIT_TAG) $(ROOT_DIR) + -t $(LATEST_TAG) $(ROOT_DIR) + +snapshot: + bash $(ROOT_DIR)/take_snapshot.sh lint: docker run -it --rm -v "$(ROOT_DIR)/Dockerfile:/Dockerfile:ro" redcoolbeans/dockerlint tag: - docker tag $(GIT_TAG) $(BUILD_TAG) - docker tag $(GIT_TAG) $(LATEST_TAG) + docker tag $(LATEST_TAG) $(BUILD_TAG) + docker tag $(LATEST_TAG) $(GIT_TAG) + docker tag $(SNAPSHOT_LATEST_TAG) $(SNAPSHOT_BUILD_TAG) + docker tag $(SNAPSHOT_LATEST_TAG) $(SNAPSHOT_GIT_TAG) push: docker push $(GIT_TAG) diff --git a/templates/take_snapshot.sh b/templates/take_snapshot.sh index ce746fb..1cff5e2 100644 --- a/templates/take_snapshot.sh +++ b/templates/take_snapshot.sh @@ -10,5 +10,5 @@ docker cp snapshot.sh emulator:/snapshot.sh docker cp snapshot.expect emulator:/snapshot.expect docker exec -t emulator bash -c "bash /snapshot.sh; exit" echo "Creating new image" -docker commit -m "Snapshot!" --change "CMD [\"/start.sh\"]" emulator agoda/docker-emulator-{{ platform }}-snapshot +docker commit -m "Snapshot!" --change "CMD [\"/start.sh\"]" emulator agoda/docker-emulator-snapshot-{{ platform }} docker rm -f emulator