Skip to content

Commit 69e356b

Browse files
committed
pass docker command on restarting
1 parent 1f954ca commit 69e356b

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

bin/restart-after-tag.sh

+7-15
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ function getTags() {
1414

1515
function restartContainer() {
1616
REPOSITORY=$1
17-
PORTS=$2
17+
COMMAND="$2"
1818
echo "New version of ${REPOSITORY} available. Deploying..."
1919
docker stop $(docker ps -q --filter ancestor=${REPOSITORY})
2020
docker rm $(docker ps -q -f status=exited)
2121
docker rmi $(docker images -q -f dangling=true)
2222
docker pull ${REPOSITORY}
23-
docker run --restart=always -d -p ${PORTS} ${REPOSITORY}
23+
eval "${COMMAND} ${REPOSITORY}"
2424
}
2525

2626
function checkForNewVersion() {
2727
REPOSITORY=$1
28-
PORTS=$2
28+
COMMAND="$2"
2929
CURRENT_TAGS_FILE=`tagsFile ${REPOSITORY} "current"`
3030
NEW_TAGS_FILE=`tagsFile ${REPOSITORY} "new"`
3131
if [ -f ${CURRENT_TAGS_FILE} ];
@@ -36,27 +36,19 @@ function checkForNewVersion() {
3636
if [ "${FILES_DIFF}" != "" ];
3737
then
3838
getTags ${REPOSITORY} ${CURRENT_TAGS_FILE}
39-
restartContainer ${REPOSITORY} ${PORTS}
39+
restartContainer "${REPOSITORY}" "${COMMAND}"
4040
fi
4141
else
4242
getTags ${REPOSITORY} ${CURRENT_TAGS_FILE}
43-
restartContainer ${REPOSITORY} ${PORTS}
43+
restartContainer "${REPOSITORY}" "${COMMAND}"
4444
fi
4545
}
4646

4747

4848
DOCKER_HUB_REPOSITORY=$1
49-
EXPOSED_PORTS=$2
50-
51-
checkForNewVersion ${DOCKER_HUB_REPOSITORY} ${EXPOSED_PORTS}
52-
53-
54-
55-
56-
57-
58-
49+
COMMAND="$2"
5950

51+
checkForNewVersion ${DOCKER_HUB_REPOSITORY} "${COMMAND}"
6052

6153

6254

0 commit comments

Comments
 (0)