Build push image to the right place and adjust makefile to use script (#35)

* build push docker image

* Update build-push-featurebranch.sh
This commit is contained in:
gadotroee 2021-05-09 12:05:05 +03:00 committed by GitHub
parent 3f0ce35de0
commit c3d0941d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View File

@ -17,8 +17,6 @@ help: ## This help.
# Variables and lists # Variables and lists
TS_SUFFIX="$(shell date '+%s')" TS_SUFFIX="$(shell date '+%s')"
DOCKER_IMG="up9inc/mizu"
DOCKER_TAG="latest"
ui: ## build UI ui: ## build UI
@(cd ui; npm i ; npm run build; ) @(cd ui; npm i ; npm run build; )
@ -38,8 +36,7 @@ tap: ## build tap binary
docker: ## build Docker image docker: ## build Docker image
@(echo "building docker image" ) @(echo "building docker image" )
docker build -t ${DOCKER_IMG}:${DOCKER_TAG} . ./build-push-featurebranch.sh
docker images ${DOCKER_IMG}
publish: ## build and publish Mizu docker image & CLI publish: ## build and publish Mizu docker image & CLI
@echo "publishing Docker image .. " @echo "publishing Docker image .. "

20
build-push-featurebranch.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
SERVER_NAME=mizu
GCP_PROJECT=up9-docker-hub
REPOSITORY=gcr.io/$GCP_PROJECT
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]')
DOCKER_TAGGED_BUILD=$REPOSITORY/$SERVER_NAME/$GIT_BRANCH:latest
if [ "$GIT_BRANCH" = 'develop' -o "$GIT_BRANCH" = 'master' -o "$GIT_BRANCH" = 'main' ]
then
echo "Pushing to $GIT_BRANCH is allowed only via CI"
exit 1
fi
echo "building $DOCKER_TAGGED_BUILD"
docker build -t "$DOCKER_TAGGED_BUILD" .
echo pushing to "$REPOSITORY"
docker push "$DOCKER_TAGGED_BUILD"