Skip to content

Commit

Permalink
[#167608825] added make publish
Browse files Browse the repository at this point in the history
Co-authored-by: Rash <[email protected]>
  • Loading branch information
Ernie Billing committed Oct 9, 2019
1 parent ad14f07 commit a3e1e19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('isv-ci:app (test generator)', () => {
assert.jsonFileContent('needs.json', []);

// makefile
assert.fileContent('Makefile', "IMAGE_TAG := \"my-test\"\n");
assert.fileContent('Makefile', "IMAGE_NAME := \"my-test\"\n");

// Dockerfile
assert.file('Dockerfile');
Expand Down
21 changes: 16 additions & 5 deletions app/templates/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
SHELL=/bin/bash

.PHONY: deps-test clean lint test build publish run shell needs-list needs-check

# TODO phonies
IMAGE_TAG := "<%= testName %>"
IMAGE_NAME := "<%= testName %>"
BASH_SRC := $(shell find . -name "*.sh")
SRC := $(BASH_SRC) needs.json Dockerfile
TEST_SRC := $(shell find . -name "*.bats")
# DOCKER_REPO := <fill in your DOCKER_REPO>


temp/test-helpers.bash:
mkdir -p temp
Expand Down Expand Up @@ -33,7 +37,7 @@ endif

clean:
rm -rf temp
docker image rm -f $(IMAGE_TAG)
docker image rm -f $(IMAGE_NAME)
rm -rf ./logs

temp/make-tags/lint: $(BASH_SRC)
Expand All @@ -49,11 +53,18 @@ temp/make-tags/test: temp/bats-mock.bash temp/test-helpers.bash $(BASH_SRC) $(TE
test: deps-test temp/make-tags/lint temp/make-tags/test

temp/make-tags/build: temp/make-tags/lint temp/make-tags/test $(SRC)
docker build . --tag $(IMAGE_TAG)
docker build . --tag $(IMAGE_NAME)
mkdir -p temp/make-tags && touch temp/make-tags/build

build: temp/make-tags/build

publish: build
ifndef DOCKER_REPO
$(error "Please define DOCKER_REPO location to publish image")
endif
docker tag $(IMAGE_NAME) $(DOCKER_REPO)/$(IMAGE_NAME):latest
docker push $(DOCKER_REPO)/$(IMAGE_NAME):latest

run-deps: build

logs:
Expand All @@ -62,13 +73,13 @@ logs:
run: run-deps logs temp/make-tags/build
set -o pipefail; docker run \
-e GREETING_NAME \
$(IMAGE_TAG) 2>&1 | tee ./logs/$(shell date "+%Y.%m.%d-%H.%M.%S").log
$(IMAGE_NAME) 2>&1 | tee ./logs/$(shell date "+%Y.%m.%d-%H.%M.%S").log

define run-docker-interactive
docker run -it \
-e GREETING_NAME \
-v ${PWD}:/test \
$(IMAGE_TAG) \
$(IMAGE_NAME) \
$1 $2
endef

Expand Down

0 comments on commit a3e1e19

Please sign in to comment.