mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Building on windows #273

Closed tantanchen closed 5 years ago

tantanchen commented 6 years ago

Building from source on windows wasn't too difficult but it looks like GitBash won't allow service init to select an option. It just terminates the program image

antho1404 commented 6 years ago

Thanks a lot for this issue and for taking the time to build on windows :) I think the issue might be related to a path that is a different system between unix system and window system but it definitely needs some investigations

ahonegger commented 6 years ago

i have a great interest in getting to the bottom of this as well, basically what i tried is to use windows containers, meaning not going via mingw. I think i found something suspicious worth investigating with the was sockets are used, via URL unix:///tmp/my_socket. the bottom line is that when you try to use mesg-core outside a unix-like environment you basically hit a brick wall, but i will keep digging :)

NicolasMahe commented 6 years ago

Yes, MESG Core's container try to access Docker via socket.. We should update this to be compatible in not UNIX environment. Also, a lot of path are hardcoded with /. We should also update them by the path functions that are compatible with non UNIX environment.

If you want, I can dig the codebase and make a list of things that should be updated for MESG Core to be compatible with Windows. Tell me if you want this list ;)

ahonegger commented 6 years ago

yes that would be great to have such a list, as i am a little limited on spare time right now.

maybe a few more insights that might help. there are actually 2 ways you can work with docker containers under windows. either you create linux containers or windows containers. for simplicity sake i think we should focus on linux containers for now, which means that most likely whatever is running inside the container (core and/or daemon) will not need much changes, except where there is mounts of local windows directories. but what i think needs changes is the cli, which would be run in either windows cmd or ps (powershell).

what makes this a little slow for me is that i don't know everything yet about the codebase, meaning what belongs to cli and what belongs to the image running in the linux container. however it is actually not a bad thing, since it forces me to go through the entire codebase carefully.

hope the above makes kinda sense :)

tantanchen commented 6 years ago

I was able to get further using windows powershell image

NicolasMahe commented 6 years ago

Yes, I also think we should only works with Linux container. It will be very complicated to force all services to run perfectly on both windows and linux container. Let's just go with Linux container as standard.

But definitely, the CLI should run on Windows.

Here is the list of things that need to change (this list may not be exhaustive):

Path to the docker's socket shared in the core's container To be able to start new container from the core's container, we give it access to the host docker's socket. The path is a constant defined here: https://github.com/mesg-foundation/core/blob/6cf76f6f184863e77c5f7de9ffd34e587ec8aa9c/daemon/const.go#L5 and it's injected in the docker's service here: https://github.com/mesg-foundation/core/blob/6cf76f6f184863e77c5f7de9ffd34e587ec8aa9c/daemon/start.go#L39-L42 We should try to get the docker socket directly from a docker config (docker may inject the path in an ENV variable on the host so the CLI could read it).

Path in UNIX style I think the biggest issue is the hardcoded paths in Unix style. We should use the filepath.Join instead of /. This is not a complicated modification but pretty long as we need to check every file.

The config file should be double check (anyway, this file needs to be improved because it's a big mess https://github.com/mesg-foundation/core/issues/290): https://github.com/mesg-foundation/core/blob/dev/config/api.go

Also this line: https://github.com/mesg-foundation/core/blob/6cf76f6f184863e77c5f7de9ffd34e587ec8aa9c/cmd/service/init.go#L73

And I'm pretty sure the list of files having hardcoded path containing / is way longer...

krhubert commented 5 years ago

We don't support windows for now and not in near feature. If we want to support it then we will have to test it. todo close