grrttedwards / wow-addon-updater

Python utility for updating World of Warcraft addons
GNU General Public License v3.0
71 stars 14 forks source link

run updater inside a docker container #194

Open dune89 opened 2 years ago

dune89 commented 2 years ago

Hi there,

did someone ever ran wow-addon-updater inside a docker container on Windows+WSL.

Sadly i have not much experience with python or wsl. Im getting this exception: Traceback (most recent call last): File "/wow-addon-updater-master/updater/__main__.py", line 78, in main AddonManager(args.config).update_all() File "/wow-addon-updater-master/updater/manager/addon_manager.py", line 59, in __init__ self.wow_addon_location = normalize_path(self.wow_addon_location) File "/wow-addon-updater-master/updater/manager/addon_manager.py", line 31, in normalize_path return subprocess.check_output(['wslpath', path], text=True).strip() File "/usr/local/lib/python3.10/subprocess.py", line 420, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/local/lib/python3.10/subprocess.py", line 501, in run with Popen(*popenargs, **kwargs) as process: File "/usr/local/lib/python3.10/subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.10/subprocess.py", line 1845, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'wslpath'

in my config.ini file i wrote /addons with the intention to bind that folder as docker-volume in future. when resolving /addons it seems to have problems while converting to wslpath (dont know why that is needed)

is this a case of simple missconfiguration of my docker file or wsl system?

thats my Dockerfile: Dockerfile.txt

best regards

Matthias

grrttedwards commented 2 years ago

Hi there. Full disclosure, I don’t play WoW anymore and therefore don’t actively maintain this project. But I’m still willing to try to support you here.

There is a feature a user of WSL had asked for which specifically handles running the tool directly under WSL, and that must be what you’re running into.

https://github.com/grrttedwards/wow-addon-updater/blob/master/updater/manager/addon_manager.py#L31

Can you show the result of the following snippet run in your container there?

import platform
print(platform.platform().lower())
dune89 commented 2 years ago

Hi there,

it looks like it is the same value as in wsl:

wsl: linux-5.10.16.3-microsoft-standard-wsl2-x86_64-with-glibc2.35 docker: linux-5.10.16.3-microsoft-standard-wsl2-x86_64-with-glibc2.31

so yes its executing the process "wslpath" which is available only on wsl.

i found a code smple from jaraco, giving the capability to see if its inside a docker container: def text_in_file(text, filename): return any(text in line for line in open(filename)) def is_docker(): return ( os.path.exists('/.dockerenv') or text_in_file('docker', '/proc/self/cgroup') )

maybe this coud be used not translating the "wslpath"

axlroden commented 2 years ago

Are you mounting the wow addon folder inside the docker container ? Otherwise it can't reach it.. Docker has no access to OS folders unless specifically mounted in there.

dune89 commented 2 years ago

For the beginning i didnt mount anything, i created a folder /addons in the container with the intention to mount that as volume in future. The problem is that it trys to translate wsl path which is not needed at that point. The code should look if its running inside a docker container and if yes, it should take path as it is. only when its wsl and not inside docker it should translate the path.

axlroden commented 2 years ago

He runs some checks to see if your in linux to get the wsl path, but docker is of course not WSL, if this is just for your docker, delete line 59 of /updater/manager/addon_manager.py and you should be good to go.

Another question would be... why are you doing this ? It would be easier to create a self contained exe than having to run this in docker.

axlroden commented 2 years ago

Also consider changing your Dockerfile to be easier on image size and faster rebuildspeeds..

Below Dockerfile deletes the line in question as well, so should be ready to go.

FROM python:3.10.5-slim-bullseye

LABEL name="python wow addon updater"

USER root

RUN mkdir /addons && apt-get update -y \
&& apt-get install git -y && apt-get clean all -y && pip install pipenv
RUN git clone https://github.com/grrttedwards/wow-addon-updater.git --depth 1
RUN cd /wow-addon-updater && pipenv install 
# Delete line 59 to fix pathing issues in docker
RUN sed -i '59d' /wow-addon-updater/updater/manager/addon_manager.py

ADD ./config.ini /wow-addon-updater/config.ini
ADD ./addons.txt /wow-addon-updater/addons.txt

CMD ["/bin/bash"]