Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
docker-makefile-sample
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sample
docker-makefile-sample
Commits
f75207c2
Commit
f75207c2
authored
Mar 06, 2019
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function to manipulate docker image
parent
0ef7e2e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
Makefile
+31
-2
No files found.
Makefile
View file @
f75207c2
# a helper shell script
MAKE_VERSION
=
1.1.
2
MAKE_VERSION
=
1.1.
3
define
MAKEFUNCTIONCODE
function
hasChanges()
{
...
...
@@ -106,8 +106,25 @@ TAG=$(shell . $(RELEASE_SUPPORT); getTag)
RELEASE_SUPPORT
:=
$(
shell
dirname
$
(
abspath
$
(
lastword
$(MAKEFILE_LIST))))
/.make-function
export
MAKEFUNCTIONCODE
# If the first argument is "run"...
doit
=
ifeq
(rmi,$(firstword
$(MAKECMDGOALS)))
doit
=
true
endif
ifeq
(images,$(firstword
$(MAKECMDGOALS)))
doit
=
true
endif
ifdef
doit
# use the rest as arguments for "run"
RMI_ARGS
:=
$
(
wordlist 2,
$
(
words
$(MAKECMDGOALS)
)
,
$(MAKECMDGOALS)
)
# ...and turn them into do-nothing targets
$(eval $(RMI_ARGS)
:
;@:)
endif
.PHONY
:
pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag show-tag
\
push do-push post-push post-init update-make
push do-push post-push post-init update-make
rmi images
init
:
@
echo
"
$$
MAKEFUNCTIONCODE"
>
./.make-function
...
...
@@ -141,6 +158,10 @@ release: check-status check-release build push
push
:
init do-push post-push
rmi
:
delete-docker-image
images
:
list-docker-image
do-push
:
docker push
$(IMAGE)
:
$(VERSION)
docker push
$(IMAGE)
:latest
...
...
@@ -200,3 +221,11 @@ update-make: init
make-version
:
@
echo
$(MAKE_VERSION)
# awk to cut the column 3, xargs to run command passing arg from pipe
delete-docker-image
:
@
docker images |
grep
$(RMI_ARGS)
| awk
'{print $$3}'
| xargs docker rmi
||
true
# || true to force exoit code to 0 otherwise if no line matched, make will show some error
list-docker-image
:
@
docker images |
grep
$(RMI_ARGS)
||
true
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment