Однако у меня возникают проблемы с отсутствием лицензий SDK. принимается в процессе сборки Docker, несмотря на использование echo y | sdkmanager --licenses для их принятия. Сборка завершается с ошибкой при попытке установить компоненты Android SDK, такие как платформы;android-33 или system-images;android-33;google_apis;x86_64.
Ниже мой Dockerfile:
Код: Выделить всё
# Use the Windows Server Core base image for Windows Server 2019
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Install dependencies using PowerShell
RUN powershell -Command \
"Invoke-WebRequest -Uri 'https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.zip' -OutFile 'jdk.zip'; \
Expand-Archive -Path '.\\jdk.zip' -DestinationPath 'C:\\Program Files\\Java'; \
Remove-Item -Force 'jdk.zip'; \
Invoke-WebRequest -Uri 'https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2021.3.1.17/android-studio-2021.3.1.17-windows.zip' -OutFile 'android-studio.zip'; \
Expand-Archive -Path 'android-studio.zip' -DestinationPath 'C:\\Program Files'; \
Remove-Item -Force 'android-studio.zip'; \
New-Item -Path 'C:\\Android\\cmdline-tools' -ItemType Directory; \
Invoke-WebRequest -Uri 'https://dl.google.com/android/repository/commandlinetools-win-7302050_latest.zip' -OutFile 'sdk-tools.zip'; \
Expand-Archive -Path 'sdk-tools.zip' -DestinationPath 'C:\\Android\\cmdline-tools'; \
Remove-Item -Force 'sdk-tools.zip';"
# Set environment variables
ENV JAVA_HOME="C:\\Program Files\\Java\\jdk-17.0.12"
ENV PATH="${JAVA_HOME}\\bin;C:\\Program Files\\nodejs;C:\\Python310\\;C:\\Android\\cmdline-tools\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;%PATH%"
ENV ANDROID_HOME="C:\\Android"
# License acceptance using echo y method
RUN powershell -Command \
"$licenses = @('platforms;android-33', 'platform-tools', 'system-images;android-33;google_apis;x86_64', 'emulator'); \
foreach ($license in $licenses) { \
Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'echo y | C:\\Android\\cmdline-tools\\cmdline-tools\\bin\\sdkmanager.bat', $license, '--sdk_root=C:\\Android' -NoNewWindow -Wait; \
}"
# Install Android SDK components
RUN powershell -Command "& 'C:\\Android\\cmdline-tools\\cmdline-tools\\bin\\sdkmanager.bat' --update"
RUN powershell -Command "& 'C:\\Android\\cmdline-tools\\cmdline-tools\\bin\\sdkmanager.bat' 'platform-tools' 'emulator' 'platforms;android-33' 'system-images;android-33;google_apis;x86_64'"
# Install Python, Node.js, and Appium (omitted for brevity)
# (Additional setup steps for Python, Node.js, and Robot Framework)
# Set the entrypoint for script execution
ENTRYPOINT ["powershell.exe", "C:\\script.ps1"]
- Использование echo y | sdkmanager --licenses для принятия лицензий.
- Создан цикл PowerShell для обработки каждой лицензии с помощью Start-Process с cmd.exe, чтобы гарантировать принятие правильно передано по конвейеру.
- Проверено, что инструменты Android SDK и пути к среде правильно настроены в контейнере.
Код: Выделить всё
Accept? (y/N): Skipping following packages as the license is not accepted:
Android SDK Platform 33
Android Emulator
Google APIs Intel x86_64 Atom System Image
Android SDK Platform-Tools
The following packages can not be installed since their licenses or those of the packages they depend on were not accepted:
system-images;android-33;google_apis;x86_64
platform-tools
platforms;android-33
emulator
Как правильно автоматизировать прием лицензий Android SDK в контейнере Docker на базе Windows Server Core? Существуют ли какие-либо конкретные конфигурации или альтернативные методы, обеспечивающие принятие лицензий в процессе сборки?
Дополнительная информация:
- Базовый образ: Windows Server Core 2019 (ltsc2019)
- Версия Java: JDK 17
- Android SDK: инструменты командной строки версии 7302050
Python, Node.js, Appium: установлены для автоматизации мобильного тестирования с помощью Robot Framework.
Подробнее здесь: https://stackoverflow.com/questions/790 ... e-on-docke
Мобильная версия