@@ -56,6 +56,8 @@ REGISTRY_ACCOUNT?=
56
56
REGISTRY_PASSWORD? =
57
57
REPOSITORY? =${_default_repository}
58
58
TAG? =${_default_tag}
59
+ # NEW_REPOSITORY format shall like: ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}[-${PUSH_TIME}]
60
+ NEW_REPOSITORY? =
59
61
60
62
# image id
61
63
IMAGE_ID? =
@@ -110,9 +112,9 @@ ifeq (,$(strip ${TAG}))
110
112
$(warning [init] input param [TAG=], change to [TAG=${TAG}])
111
113
endif
112
114
113
- # if set, shall with path, absoulte better
115
+ # if set, shall with path, absolute better
114
116
DOCKER_FILE? =${PROJECT_ROOT}/${_default_docker_file_name}
115
- # if set, shall with path, absoulte better
117
+ # if set, shall with path, absolute better
116
118
DOCKER_COMPOSE_FILE? =${PROJECT_ROOT}/${_default_docker_compose_file_name}
117
119
118
120
# check or override: DOCKER_FILE
@@ -127,7 +129,7 @@ ifeq (,$(strip ${DOCKER_COMPOSE_FILE}))
127
129
$(warning [init] input param [DOCKER_COMPOSE_FILE=], change to [DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_FILE}])
128
130
endif
129
131
130
- # full image name: rerpository :tag
132
+ # full image name: repository :tag
131
133
build_image_repository_name =${REPOSITORY}:${TAG}
132
134
133
135
_git_version =$(shell if [ -x $(command -v git ) ]; then git --version | sed -En "s/([^0-9]* ) ([0-9\.]+)([^0-9]*.*)/\2/ p"; fi)
@@ -160,6 +162,7 @@ endif
160
162
# ----------- Makefile commands -----------
161
163
.PHONY : default help env cp-ignore \
162
164
login login-auth build tag push list-image list-docker\
165
+ once-tag once-push \
163
166
run stop \
164
167
rmi image-prune rm docker-prune compose-run compose-stop \
165
168
logs
@@ -187,7 +190,7 @@ login:
187
190
docker login
188
191
@echo -e " [command-login] ${GREEN} execute success${COLOR_RESET} "
189
192
190
- # # login-auth: login docker-hub or the specied REGISTRY
193
+ # # login-auth: login docker-hub or the special REGISTRY
191
194
login-auth :
192
195
docker login -u " ${REGISTRY_ACCOUNT} " " ${REGISTRY} " -p " ${REGISTRY_PASSWORD} "
193
196
@echo -e " [command-login-auth] ${GREEN} execute success${COLOR_RESET} "
@@ -210,6 +213,17 @@ push:
210
213
docker push ${REPOSITORY} :${TAG}
211
214
@echo -e " [command-push] ${GREEN} push ${REPOSITORY} :${TAG} over${COLOR_RESET} "
212
215
216
+ # # once-tag: docker tag, rename old to the specified tag
217
+ once-tag :
218
+ @docker tag ${REPOSITORY} :${TAG} ${NEW_REPOSITORY}
219
+ @echo -e " [command-once-tag] ${GREEN} image [${REPOSITORY} :${TAG} ], rename to [${NEW_REPOSITORY}${COLOR_RESET} ]"
220
+ @echo -e " [command-once-tag] ${GREEN} execute success${COLOR_RESET} "
221
+
222
+ # # once-push: push docker images with the specified tag to docker hub or others. shall login before push!
223
+ once-push :
224
+ docker push ${NEW_REPOSITORY}
225
+ @echo -e " [command-once-push] ${GREEN} push ${NEW_REPOSITORY} over${COLOR_RESET} "
226
+
213
227
# # list-image: list docker images, can with filter, -f reference="", ref 'docker images --help'
214
228
list-image :
215
229
@docker images ${IMAGE_LIST_PARAMS}
0 commit comments