@@ -308,6 +308,7 @@ string(TOLOWER "${NABLA_DEV_ENV_CT_NAME}" NABLA_DEV_ENV_CT_NAME)
308308set (COMPOSE_NSC_DEV_SERVICE compiler-explorer-nsc-dev)
309309string (TOLOWER "dr.devsh.eu/nabla/cmake-host-dev-env/${CMAKE_SYSTEM_NAME} /build/${CMAKE_CXX_COMPILER_ID} /compiler-explorer-nsc:latest" COMPOSE_NSC_DEV_IMAGE)
310310string (TOLOWER "dr.devsh.eu/compiler-explorer/production/windows/nsc/orphan-production-test:latest" COMPOSE_NSC_ORPHAN_PRODUCTION_TEST_IMAGE)
311+ string (TOLOWER "dr.devsh.eu/compiler-explorer/production/windows/nsc/orphan-prodution-cache:latest" COMPOSE_NSC_PRODUCTION_CACHE_IMAGE)
311312string (TOLOWER "dr.devsh.eu/compiler-explorer/production/windows/nsc:latest" COMPOSE_NSC_PRODUCTION_IMAGE)
312313
313314string (APPEND COMPOSE_CONTENT
@@ -382,6 +383,11 @@ exit /b 0
382383string (CONFIGURE "${BAT_PRODUCTION_INSTALL} " BAT_PRODUCTION_INSTALL @ONLY)
383384file (WRITE "${NBL_DOCKER_CT_NSC_INSTALL_BAT} " "${BAT_PRODUCTION_INSTALL} " )
384385
386+ set (NBL_CE_URL http://localhost:80)
387+ set (NBL_CE_HEALTHY_CHECK_PY "${NBL_ROOT_PATH} /docker/compiler-explorer/ce_healthy_check.py" )
388+ set (NBL_CE_ENDPOINT_PY "${NBL_ROOT_PATH} /docker/compiler-explorer/endpoint.py" )
389+ set (NBL_NSC_BASIC_HLSL_JPAYLOAD "${CMAKE_CURRENT_SOURCE_DIR} /docker/godbolt/hlsl-basic-compile-payload.json" )
390+
385391add_custom_target (run-compiler-explorer
386392 COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Performing Pre-Test..."
387393 COMMAND "${CTEST_EXE} " -C $<CONFIG> --stop-on -failure
@@ -392,15 +398,19 @@ add_custom_target(run-compiler-explorer
392398 COMMAND "${CMAKE_COMMAND} " -E copy_directory "${NBL_NSC_PREINSTALL_DIRECTORY} " "${NBL_DOCKER_CT_NSC_VOLUME_SOURCE} "
393399 COMMAND "${DOCKER_EXE} " compose -f "${NBL_DOCKER_CE_COMPOSE_TARGET} " up -d ${COMPOSE_NSC_DEV_SERVICE}
394400 COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Checking health of Compiler Explorer service..."
395- COMMAND "${_Python3_EXECUTABLE} " "${NBL_ROOT_PATH} /docker/compiler-explorer/ce_healthy_check.py " --url http://localhost:80 --interval 10 --ticks 25
401+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_HEALTHY_CHECK_PY} " --url " ${NBL_CE_URL} " --interval 10 --ticks 25
396402 COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "Compiler Explorer is running, type \" localhost\" in your browser!"
403+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Post-Checking if NSC is able to compile basic shader file..."
404+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compiler/nsc_$<LOWER_CASE:$<CONFIG>>_upstream/compile --method POST --json "${NBL_NSC_BASIC_HLSL_JPAYLOAD} "
405+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "OK! NSC is healthy."
397406 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
398407 VERBATIM
399408 USES_TERMINAL
400409)
401410
402411add_custom_target (is-compiler-explorer-running
403- COMMAND "${_Python3_EXECUTABLE} " "${NBL_ROOT_PATH} /docker/compiler-explorer/ce_healthy_check.py" --url http://localhost:80 --ticks 1
412+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_HEALTHY_CHECK_PY} " --url "${NBL_CE_URL} " --ticks 1
413+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compilers
404414 VERBATIM
405415 USES_TERMINAL
406416)
@@ -424,20 +434,38 @@ ENTRYPOINT ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command", "npm", "
424434[=[
425435
426436]=]
427- nsc-ce-production
428- nsc.ce.production
429- ${COMPOSE_NSC_PRODUCTION_IMAGE }
437+ nsc-ce-production- cache -webpack
438+ nsc.ce.production. cache .webpack
439+ ${COMPOSE_NSC_PRODUCTION_CACHE_IMAGE }
430440OFF
431441)
432442
443+ set (NBL_CE_URL http://localhost:6969)
444+
433445add_custom_target (create-production-compiler-explorer
446+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Removing any remaining pre-test orphan containers..."
447+ COMMAND "${DOCKER_EXE} " rm -f production-ce-orphan-run-test || "${CMAKE_COMMAND} " -E true
448+ COMMAND "${DOCKER_EXE} " rm -f production-ce-orphan-cache -webpack || "${CMAKE_COMMAND} " -E true
449+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Creating pre-test production image..."
434450 COMMAND "${DOCKER_EXE} " run -dit -v "${NBL_DOCKER_CT_NSC_VOLUME_SOURCE} :${NBL_DOCKER_TMP_PRODUCTION_TARGET} " --name production-ce-orphan-run-test --entrypoint "cmd" "${COMPOSE_NSC_DEV_IMAGE} "
435451 COMMAND "${DOCKER_EXE} " exec production-ce-orphan-run-test "${NBL_DOCKER_TMP_PRODUCTION_TARGET} \\ ${NBL_DOCKER_INSTALL_BAT_FILENAME} "
436452 COMMAND "${DOCKER_EXE} " stop production-ce-orphan-run-test
437- COMMAND "${DOCKER_EXE} " commit production-ce-orphan-run-test "${COMPOSE_NSC_ORPHAN_PRODUCTION_TEST_IMAGE} "
453+ COMMAND "${DOCKER_EXE} " commit -m "Copy NSC install redists" production-ce-orphan-run-test "${COMPOSE_NSC_ORPHAN_PRODUCTION_TEST_IMAGE} "
438454 COMMAND "${DOCKER_EXE} " compose build
439- # TODO (Yas): here -> run built final image, use host ce_healthy_check to detect if you see godbolt, then use some REST API (POST/GET) to collect ALL compilers from godbolt, check if they are all 3 and nsc_* named, check if they can all still compile basic HLSL input without crashing in the production
440- # you can actually tag it with "-test" and if passes tests then tag as final :latest image
455+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Running pre-test production image, caching webpack & running final checks..."
456+ COMMAND "${DOCKER_EXE} " run -dit -p 6969:10240 --name production-ce-orphan-cache -webpack "${COMPOSE_NSC_PRODUCTION_CACHE_IMAGE} "
457+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_HEALTHY_CHECK_PY} " --url "${NBL_CE_URL} " --interval 10 --ticks 35
458+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compilers --disable-cookies --timeout 69
459+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compiler/nsc_release_upstream/compile --method POST --json "${NBL_NSC_BASIC_HLSL_JPAYLOAD} " --disable-cookies --timeout 69
460+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compiler/nsc_relwithdebinfo_upstream/compile --method POST --json "${NBL_NSC_BASIC_HLSL_JPAYLOAD} " --disable-cookies --timeout 69
461+ COMMAND "${_Python3_EXECUTABLE} " "${NBL_CE_ENDPOINT_PY} " --url "${NBL_CE_URL} " --endpoint /api/compiler/nsc_debug_upstream/compile --method POST --json "${NBL_NSC_BASIC_HLSL_JPAYLOAD} " --disable-cookies --timeout 69
462+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --blue "Passed all tests! Creating final production image..."
463+ COMMAND "${DOCKER_EXE} " stop production-ce-orphan-cache -webpack
464+ COMMAND "${DOCKER_EXE} " commit -m "Perform tests, cache webpack build" production-ce-orphan-cache -webpack "${COMPOSE_NSC_PRODUCTION_IMAGE} "
465+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --green "Created final `${COMPOSE_NSC_PRODUCTION_IMAGE} ` production image!"
466+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --green "To run the production image, execute: 'docker run -p 80:10240 ${COMPOSE_NSC_PRODUCTION_IMAGE} ',"
467+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --green "'docker run -p 80:10240 ${COMPOSE_NSC_PRODUCTION_IMAGE} '."
468+ COMMAND "${CMAKE_COMMAND} " -E cmake_echo_color --green "The production image can be pushed safely to the public registry."
441469 WORKING_DIRECTORY "${OUTPUT_DIRECTORY} "
442470 VERBATIM
443471 USES_TERMINAL
0 commit comments