-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makefile/docker.inc.mk: Expose docker volume mount args #14200
Conversation
Only for use when using BUILD_IN_DOCKER=1 and using a different docker container. Add DOCKER_VOLUME_NAME to override the default volume name. Add DOCKER_VOLUME_MOUNT_PATH to override default mounting path. Allow DOCKER_RIOTPROJECT to be overridden when changing defaults and being outside RIOT. In order to run BUILD_IN_DOCKER within a docker instance there parameters must be exposed. Since true docker in docker is not always straight forward the recommend way is just exposing the hosts docker command.
There might be a better way of doing this but so far this is the only way I could make it work without changing the system. Since @cladmi is not longer here it seems @fjmolinas or @maribu would be next in line. |
I also don't know if this stuff should be documented somewhere such as vars.inc.mk or in a readme. This really is just fine tuning for cornercases when using BUILD_IN_DOCKER. |
makefiles/docker.inc.mk
Outdated
@@ -219,15 +219,22 @@ _docker_volume_mapping = $(if $1,$(if $(call dir_is_outside_riotbase,$1),$(call | |||
docker_environ_mapping = $(addprefix -e ,$(call docker_cmdline_mapping,$1,$2,$3)) | |||
docker_cmdline_mapping = $(if $($1),'$1=$(call path_in_docker,$($1),$2,$3)') | |||
|
|||
# Name of the docker volue contianing RIOT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Name of the docker volue contianing RIOT. | |
# Name of the docker volume containing RIOT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for taking a look @cladmi, fixed!
I do not fully understand the goal. However, this PR does not change any configuration, but only allows users to do so if they want to. There is certainly no harm in that. I wonder if it might make sense to have a |
@maribu Thanks for the feedback, I will namespace better. The goal is to be able to run a CI (in this case Jenkins) in docker while using the hosts version of docker for the BUILD_IN_DOCKER. The real docker in docker approach seems to be not recommend for this case and merging the two docker images is not exactly trival. With finer grain control over the volume I can expose the RIOT that would exist in the CI docker container to the BUILD_IN_RIOT docker container. |
In that case, not sure why you need the |
It is my workaround because The ideal way would be to add a I would like to get something like this:
|
So the goal for you, is to trick/configure to mount not the riot directory but another one which has RIOT inside. The logic is indeed quite based on the fact that the base directory mounted is I did not execute to see how what you would want is different from what you currently have. You should check the variables used in |
I will try that, I did play around that for a bit but not exhaustively. The also tried with the I agree that it could be more simple. |
Closing for now as I am avoiding socket docker in docker. I may reopen if it comes up later, but I still think there is a better solution. |
Contribution description
Only for use when using
BUILD_IN_DOCKER=1
and using a different docker container.Add
DOCKER_VOLUME_NAME
to override the default volume name.Add
DOCKER_VOLUME_MOUNT_PATH
to override default mounting path.Allow
DOCKER_RIOTPROJECT
to be overridden when changing defaults and being outside RIOT.In order to run BUILD_IN_DOCKER within a docker instance there parameters must be exposed.
Since true docker in docker is not always straight forward the recommend way is just exposing the hosts docker command.
Note that all defaults remain the same, this doesn't change how BUILD_IN_DOCKER can be used. It only adds optional env vars to allow for BUILD_IN_DOCKER from a docker with a socket to the host docker... I know how silly that statement sounds.
Testing procedure
written for those with docker experience
BUILD_IN_DOCKER=1 make
(it should fail since it is assuming docker is running in the container when really it is using a socket to the hosts docker)expected results for BUILD_IN_DOCKER=1 -C examples/hello-world
expect it to succeed.
For bonus points try to build with riotbase outside the directory calling make, if that is the case then the
-w
arg changes and fails. This is why theDOCKER_RIOTPROJECT
should be overwritten.Issues/PRs references