Skip to content

Commit

Permalink
Allow custom start image (IBM-Blockchain#406)
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Turner <[email protected]>
  • Loading branch information
Jakeeyturner authored Feb 18, 2021
1 parent f63b0c9 commit b9c6602
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion generators/network/templates/start.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ rem SPDX-License-Identifier: Apache-2.0
rem
setlocal enabledelayedexpansion

SET CUSTOM_IMAGE=%1
if DEFINED CUSTOM_IMAGE (
SET START_IMAGE=%CUSTOM_IMAGE%
) ELSE (
SET START_IMAGE="ibmcom/ibp-microfab:0.0.11"
)

echo "Using image: %START_IMAGE%"

FOR /F "usebackq tokens=*" %%g IN (`docker ps -f label^=fabric-environment-name^="<%= name %> Microfab" -q -a`) do (SET CONTAINER=%%g)

Expand All @@ -16,7 +24,7 @@ IF DEFINED CONTAINER (
)
) ELSE (
SET MICROFAB_CONFIG=<%-microfabConfig%>
docker run -e MICROFAB_CONFIG --label fabric-environment-name="<%= name %> Microfab" -d -p <%-port%>:<%-port%> ibmcom/ibp-microfab:0.0.11
docker run -e MICROFAB_CONFIG --label fabric-environment-name="<%= name %> Microfab" -d -p <%-port%>:<%-port%> %START_IMAGE%
)


Expand Down
13 changes: 12 additions & 1 deletion generators/network/templates/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@
#
# Exit on first error, print all commands.
set -ev

CUSTOM_IMAGE=$@
if [ -z "$CUSTOM_IMAGE" ]
then
START_IMAGE="ibmcom/ibp-microfab:0.0.11"
else
START_IMAGE=$CUSTOM_IMAGE
fi

echo "Using image: $START_IMAGE"

CONTAINER=$(docker ps -f label=fabric-environment-name="<%= name %> Microfab" -q -a)
if [ -z "$CONTAINER" ]
then
export MICROFAB_CONFIG='<%-microfabConfig%>'
docker run -e MICROFAB_CONFIG --label fabric-environment-name="<%= name %> Microfab" -d -p <%-port%>:<%-port%> ibmcom/ibp-microfab:0.0.11
docker run -e MICROFAB_CONFIG --label fabric-environment-name="<%= name %> Microfab" -d -p <%-port%>:<%-port%> $START_IMAGE
else
docker start ${CONTAINER}
fi
Expand Down

0 comments on commit b9c6602

Please sign in to comment.