jbauer opened 2 years ago
|
|||||
This seems too complicated. I am thinking of adding an environment variable so that user can pass in onedev installation directory on host directly. Will that work for your case? If that environment variable is not set, onedev continues with current logic to find the host installation directory which works for most cases. |
|||||
That would only work if you assume that the data directory of docker daemon is the same on all hosts in a docker swarm cluster. However that might not be the case. Different linux distributions might install docker into different locations. Or a node is intentionally configured differently by changing dockerd's configuration parameter Can you shortly describe how you use the onedev host installation directory when using job executors? So I can better understand the situation. |
|||||
When running a CI job using server docker executor, OneDev creates a temp directory under its installation directory, which is |
|||||
Turns out that below command can be used to determine container id of OneDev:
With the container id, it is easy to determine the host installation directory simply by inspecting the container, even if the volume is not a bind one. Docker inspect will always output source directory of the mount like below in the volumes section:
Can you please verify if this works at your side? |
|||||
OneDev changed state to 'Closed' 2 years ago
|
|||||
State changed as code fixing the issue is committed |
|||||
OneDev changed state to 'Released' 2 years ago
|
|||||
State changed as build #2237 is successful |
|||||
Robin Shen changed title 2 years ago
|
|||||
Sorry for the late reply. Yes the above command works in a docker service task. An alternative solution could be to remove the dependency on the host path completely by using a onedev-build volume. For example you could execute the following commands inside the onedev container to populate a docker volume with the build data and then run the build as usual: Preparation:
After these commands you have a volume with the required data to execute the build. That volume could then be mounted into the real target image that the user has defined for the build, just like you already do it. Run the docker job
That way you don't have to know the host path of onedev at all. |
|||||
Hmm on the other hand using the volume strategy also means occupying additional space on the host and maybe that host only has a small local disk and uses a NAS/SAN for storage. So using |
|||||
Thanks for the idea. Just as you've mentioned, placing source directory of Also there are two other reasons:
All these are much easier to be handled with bind mount knowing host directory of OneDev. |
Type |
Bug
|
Priority |
Normal
|
Assignee | |
Affected Versions |
Not Found
|
We have
docker-compose.yml
file which defines all our server side development services. That compose file is then used withdocker stack deploy -c docker-compose.yml dev-environment
so that all services are deployed to docker swarm.Once we run the above via
docker stack deploy
we get a functional onedev instance in docker swarm. However configuring docker as job executor fails with exception:Looking briefly into the code I think the reason is that you are trying to inspect the container onedev is running in. To do so you either use the
hostname
(which isonedev
in our case) or you are tryingonedev
as a fallback. Given that we deployed onedev to docker swarm as a service there is no such container.Calling
docker ps
within the onedev container results inSo you would need to call
docker container inspect dev-environment_onedev.1.gk2giempre4u9xq1q5oegyydc
ordocker container inspect 252d42474124
. But given that we have defined a custom hostname and given that you do not know about the docker stack name (dev-environment) both commands can not be generated with the available information.As a workaround we could comment the hostname in the docker-compse file, so that the container hostname will be its container id again. However we like to have a more stable hostname.
So I think it would be useful to have an environment variable in the onedev docker image to give onedev more information:
ONEDEV_SERVICE_NAME
: You could executedocker service inspect <ONEDEV_SERVICE_NAME>
, find the mounts, check wether or not it is a bind mount (done) or a volume mount. If it is a volume mount you need to follow up withdocker volume inspect <VOLUME_NAME>
to find out the current mountpoint of that volume on the host.ONEDEV_VOLUME_NAME
andONEDEV_HOST_BIND_DIR
: If the volume name is provided you again calldocker volume inspect <ONEDEV_VOLUME_NAME>
. If a bind mount is used, you simply use the provided path directly.Maybe there are other solutions but the current solution in code is a little too easy to be fully compatible with docker swarm.