build-docker.cmd 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. REM Copyright The OpenTelemetry Authors
  2. REM SPDX-License-Identifier: Apache-2.0
  3. @echo off
  4. pushd %~dp0
  5. REM Default arguments
  6. set A1="/build/tools/build.sh"
  7. set A2=clean
  8. if "%~1"=="" goto help
  9. REM Image name is always the first argument
  10. set IMAGE_NAME=%1
  11. REM Process other optional arguments
  12. shift
  13. if NOT "%1"=="" (
  14. set A1=%1
  15. set A2=%2
  16. set A3=%3
  17. set A4=%4
  18. set A5=%5
  19. set A6=%6
  20. set A7=%7
  21. set A8=%8
  22. set A9=%9
  23. set A10=%10
  24. )
  25. WHERE choco >NUL 2>NUL
  26. if %ERRORLEVEL% NEQ 0 (
  27. echo This script requires Chocolatey to install Docker: https://chocolatey.org/
  28. )
  29. WHERE docker >NUL 2>NUL
  30. if "%ERRORLEVEL%"=="0" goto docker_ok
  31. choco install -y docker-desktop
  32. choco install -y docker-cli
  33. :docker_ok
  34. docker info
  35. docker version
  36. echo Running in container %IMAGE_NAME%
  37. sc query com.docker.service
  38. REM Force reinstallation of build tools
  39. del ..\.buildtools 2>NUL
  40. echo Building docker image in %CD%...
  41. copy /Y setup-cmake.sh ..\docker\%IMAGE_NAME%\
  42. copy /Y setup-protobuf.sh ..\docker\%IMAGE_NAME%\
  43. docker build --rm -t %IMAGE_NAME% ../docker/%IMAGE_NAME%
  44. cd ..
  45. echo Starting build...
  46. docker run -it -v %CD%:/build %IMAGE_NAME% %A1% %A2%
  47. popd
  48. exit
  49. :help
  50. cd ..
  51. echo.
  52. echo Usage: build-docker.cmd [image_name] [arguments...]
  53. echo.
  54. echo Default command:
  55. echo.
  56. echo docker run -it -v $WORKSPACE_ROOT:/build IMAGE_NAME %A1% %A2%
  57. echo.
  58. echo Supported images:
  59. echo =================
  60. dir /B docker
  61. popd