Skip to content

Commit e83caef

Browse files
authored
docker support once special deal (#10)
1 parent a04f7ad commit e83caef

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

docker/Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ REGISTRY_ACCOUNT?=
5656
REGISTRY_PASSWORD?=
5757
REPOSITORY?=${_default_repository}
5858
TAG?=${_default_tag}
59+
# NEW_REPOSITORY format shall like: ${REGISTRY}/${NAMESPACE}/${IMAGE_NAME}[-${PUSH_TIME}]
60+
NEW_REPOSITORY?=
5961

6062
# image id
6163
IMAGE_ID?=
@@ -110,9 +112,9 @@ ifeq (,$(strip ${TAG}))
110112
$(warning [init] input param [TAG=], change to [TAG=${TAG}])
111113
endif
112114

113-
# if set, shall with path, absoulte better
115+
# if set, shall with path, absolute better
114116
DOCKER_FILE?=${PROJECT_ROOT}/${_default_docker_file_name}
115-
# if set, shall with path, absoulte better
117+
# if set, shall with path, absolute better
116118
DOCKER_COMPOSE_FILE?=${PROJECT_ROOT}/${_default_docker_compose_file_name}
117119

118120
# check or override: DOCKER_FILE
@@ -127,7 +129,7 @@ ifeq (,$(strip ${DOCKER_COMPOSE_FILE}))
127129
$(warning [init] input param [DOCKER_COMPOSE_FILE=], change to [DOCKER_COMPOSE_FILE=${DOCKER_COMPOSE_FILE}])
128130
endif
129131

130-
# full image name: rerpository:tag
132+
# full image name: repository:tag
131133
build_image_repository_name=${REPOSITORY}:${TAG}
132134

133135
_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
160162
# ----------- Makefile commands -----------
161163
.PHONY: default help env cp-ignore \
162164
login login-auth build tag push list-image list-docker\
165+
once-tag once-push \
163166
run stop \
164167
rmi image-prune rm docker-prune compose-run compose-stop \
165168
logs
@@ -187,7 +190,7 @@ login:
187190
docker login
188191
@echo -e "[command-login] ${GREEN}execute success${COLOR_RESET}"
189192

190-
## login-auth: login docker-hub or the specied REGISTRY
193+
## login-auth: login docker-hub or the special REGISTRY
191194
login-auth:
192195
docker login -u "${REGISTRY_ACCOUNT}" "${REGISTRY}" -p "${REGISTRY_PASSWORD}"
193196
@echo -e "[command-login-auth] ${GREEN}execute success${COLOR_RESET}"
@@ -210,6 +213,17 @@ push:
210213
docker push ${REPOSITORY}:${TAG}
211214
@echo -e "[command-push] ${GREEN}push ${REPOSITORY}:${TAG} over${COLOR_RESET}"
212215

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+
213227
## list-image: list docker images, can with filter, -f reference="", ref 'docker images --help'
214228
list-image:
215229
@docker images ${IMAGE_LIST_PARAMS}

0 commit comments

Comments
 (0)