Мы строим Docker Container на Docker Cloud. Для процесса сборки требуются подмодули git.
Чтобы инициализировать подмодули для локальной сборки, мы добавили в Dockerfile следующую строку:
RUN git submodule update --init --recursive
См .: https://github.com/open62541/open62541/blob/master/Dockerfile#L9
Соответствующий коммит: https://github.com/open62541/open62541/commit/ee9c18a6a05722edfe7c0d8d8e140d802fa2e5f2 и запрос извлечения:
https://github.com/open62541/open62541/pull/3191
Примечание: В отличие от похожих вопросов, все субмодули являются публичными репозиториями на github без аутентификации.
Ситуация без строки инициализации подмодуля:
git clone https://github.com/open62541/open62541.git
cd open62541
# Parent commit without git submodule update
git checkout e97abd591a159ce894488d93796b858d9f0d00b9
# This will fail because the submodules are obviously not initialized
docker build .
Ошибка:
CMake Error at CMakeLists.txt:830 (message):
File /opt/open62541/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml not found.
You probably need to initialize the git submodule for deps/ua-nodeset.
Ситуация с подмодулем init в Dockerfile:
Step 7/18 : RUN git submodule update --init --recursive
---> Running in b358c21c4d53
fatal: not a git repository: /src/b6tohshrfzzntavvhek3zna/.git/modules/deps/mdnsd
Unable to find current revision in submodule path 'deps/mdnsd'
git clone https://github.com/open62541/open62541.git
cd open62541
# Commit which added git submodule init in Dockerfile
git checkout ee9c18a6a05722edfe7c0d8d8e140d802fa2e5f2
# This will succeed
docker build .
Как правильно инициализируются подмодули в файлах Docker так, чтобы ониработает в облаке Docker, и в то же время можно просто вытащить основной репозиторий и построить контейнер Docker?
Смежные вопросы: