Skip to content

Commit

Permalink
Merge pull request #150 from kagaya85/release
Browse files Browse the repository at this point in the history
feat add Makefile
  • Loading branch information
kagaya85 authored Apr 20, 2021
2 parents fcdb27f + 60af219 commit d7e1826
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 24 deletions.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Codewisdom Train-Ticket system

Username=codewisdom
Tag=0.1.0

# build image
.PHONY: build
build: clean-image package build-image

.PHONY: package
package:
mvn clean package

.PHONY: build-image
build-image:
@hack/build-image.sh $(Username) $(Tag)

# push image
.PHONY: push-image
push-image:
@hack/push-image.sh $(Username)

.PHONY: clean
clean:
@mvn clean
@hack/clean-image.sh $(Username)

# clean image
.PHONY: clean-image
clean-image:
@hack/clean-image.sh $(Username)
14 changes: 14 additions & 0 deletions hack/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

echo
echo "Start build images, Repo: $1, Tag: $2"
echo
for dir in ts-*; do
if [[ -d $dir ]]; then
if [[ -n $(ls "$dir" | grep -i Dockerfile) ]]; then
echo "build ${dir}"
docker build -t "$1"/"${dir}" "$dir"
docker tag "$1"/"${dir}":latest "$1"/"${dir}":"$2"
fi
fi
done
10 changes: 10 additions & 0 deletions hack/clean-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

echo
echo "Clean images, Repo: $1"
echo
images=$(docker images | grep "$1"/ts- | awk '{print $3}')

if [[ -n "$images" ]]; then
echo "$images" | xargs -I {} docker rmi {}
fi
11 changes: 11 additions & 0 deletions hack/push-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

echo
echo "Please input you repo password of $1"
echo
docker login --username="$1"

echo
echo "Start pushing image"
echo
docker images | grep "$1/ts" | awk 'BEGIN{OFS=":"}{print $1,$2}' | xargs -I {} docker push {}
24 changes: 0 additions & 24 deletions hack/pushimg.sh

This file was deleted.

0 comments on commit d7e1826

Please sign in to comment.