Skip to content

Commit 6de984e

Browse files
committed
create docker_default network if it doesn't exist
1 parent 848d4a5 commit 6de984e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ if (NBL_WITH_DOCKER)
223223
endmacro()
224224

225225
# helper macro for calling docker, takes args as a string
226-
macro(calldocker args)
227-
execute_process(COMMAND ${DOCKER_EXECUTABLE} ${args} RESULT_VARIABLE DOCKER_EXIT_CODE OUTPUT_QUIET)
226+
macro(calldocker)
227+
execute_process(COMMAND ${DOCKER_EXECUTABLE} ${ARGN} RESULT_VARIABLE DOCKER_EXIT_CODE OUTPUT_QUIET)
228228
endmacro()
229229

230230
# check if the docker daemon is running
@@ -233,7 +233,7 @@ if (NBL_WITH_DOCKER)
233233
set(DDT_DOCKER_RESPONDING False)
234234
foreach(ATTEMPT RANGE 1 ${DDT_MAX_ATTEMPTS})
235235
message(STATUS "Attempt ${ATTEMPT} of ${DDT_MAX_ATTEMPTS}: Checking Docker Endpoint")
236-
calldocker("info")
236+
calldocker(info)
237237

238238
if (DOCKER_EXIT_CODE EQUAL 0)
239239
set(DDT_DOCKER_RESPONDING True)
@@ -247,6 +247,13 @@ if (NBL_WITH_DOCKER)
247247
message(FATAL_ERROR "Docker Daemon is not responding. Please make sure it's running in the background")
248248
endif()
249249

250+
set(DNT_NETWORK_NAME "docker_default")
251+
message(STATUS "Checking wether \"${DNT_NETWORK_NAME}\" docker network exist.")
252+
calldocker(network inspect ${DNT_NETWORK_NAME})
253+
if (NOT DOCKER_EXIT_CODE EQUAL 0)
254+
message(STATUS "Docker network \"${DNT_NETWORK_NAME}\" doesn't exist. Creating one.'")
255+
calldocker(network create -d nat ${DNT_NETWORK_NAME})
256+
endif()
250257
endif()
251258

252259
set(THIRD_PARTY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/3rdparty")

0 commit comments

Comments
 (0)