Skip to content
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

Problem with docker-compose #516

Closed
rolandgeider opened this issue Sep 7, 2020 · 12 comments
Closed

Problem with docker-compose #516

rolandgeider opened this issue Sep 7, 2020 · 12 comments
Milestone

Comments

@rolandgeider
Copy link
Member

Hi, I am having some issues setting up wget with docker-compose.

What I did was to pull the entire repo, then run docker-compose.yml, but it results in a bunch of errors

cp: cannot create regular file '/home/wger/src/settings.py': Permission denied
Waiting for postgres...
PostgreSQL started :)
Traceback (most recent call last):
  File "/usr/local/bin/wger", line 33, in <module>
    sys.exit(load_entry_point('wger', 'console_scripts', 'wger')())
  File "/usr/local/bin/wger", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.8/importlib/metadata.py", line 504, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: wger
Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    setup_django_environment(get_path('settings.py'))
  File "/home/wger/src/wger/tasks.py", line 312, in setup_django_environment
    django.setup()
  File "/usr/local/lib/python3.8/dist-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 83, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 70, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.8/dist-packages/django/conf/__init__.py", line 177, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'settings'

the docker-compose file in the extras folder seems to be exclusively focused on the dev environment, and I just want to have the latest release of wger running on my server. Any idea what could be the issue? I've tried following the docs but I am still a bit confused.

Originally posted by @AlexKalopsia in #340 (comment)

@rolandgeider
Copy link
Member Author

OK, that sounds strange, I'll see if I can reproduce it.

Yeah, the docker compose is focused on development at the moment. There is already a PR to make the code changes persist in a volume, but we're not there yet. You basically want an image that you can update regularly, right?

@rolandgeider
Copy link
Member Author

@AlexKalopsia

@AlexKalopsia
Copy link

Yeah, basically I want a stable build that I can quickly get up and running @rolandgeider

@rolandgeider rolandgeider linked a pull request Sep 8, 2020 that will close this issue
3 tasks
@rolandgeider rolandgeider added this to the 2.0 milestone Sep 8, 2020
@rolandgeider
Copy link
Member Author

I've started a new repo with only the docker-compose files to use for production-like environments: https://github.com/wger-project/docker People that don't want to develop, can just pull that and get started.

@AlexKalopsia
Copy link

@rolandgeider this is awesome, thank you so much! I would I go if I already had nginx running? Can I somehow map the wger port to a custom one?

@rolandgeider
Copy link
Member Author

Yeah, you could just edit the port in the docker-compose.yml file. But be a bit patient, this is not working 100% yet! 😅

@AlexKalopsia
Copy link

Yeah, no worries, I really appreciate the support!

@rolandgeider
Copy link
Member Author

You can give it a try now if you want

@rolandgeider
Copy link
Member Author

The original problem should be solved as well

@Dieterbe
Copy link
Contributor

Dieterbe commented May 4, 2024

i have a similar problem. when i first build the wger/server:latest image (it built successfully, after some tweaks, see #1655 ), then trying to run it:
UPDATE: i also have this issue when downloading the image from dockerhub.

$ docker run -ti  \
   -v /home/dieter/code/wger-wger:/home/wger/src \
   --name wger.devel \
   --publish 8000:8000 wger/server
cp: cannot create regular file '/home/wger/src/settings.py': Permission denied
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/wger/src
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: wger
  Building editable for wger (pyproject.toml) ... done
  Created wheel for wger: filename=wger-2.3.0a1-py3-none-any.whl size=17451 sha256=67a9177c4eb11214a3f505f8228e9ad48b14e3ca235f90d4fb20b5f1857ac37a
  Stored in directory: /tmp/pip-ephem-wheel-cache-_uulw6r2/wheels/bb/de/68/a0b92a2822ee4f4e652bee9bccfb05e9a11dec0fbf14501163
Successfully built wger
Installing collected packages: wger
Successfully installed wger-2.3.0a1
*** Creating settings file at /home/wger/src
Traceback (most recent call last):
  File "/usr/local/bin/invoke", line 8, in <module>
    sys.exit(program.run())
  File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 398, in run
    self.execute()
  File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 583, in execute
    executor.execute(*self.tasks)
  File "/usr/local/lib/python3.10/dist-packages/invoke/executor.py", line 140, in execute
    result = call.task(*args, **call.kwargs)
  File "/usr/local/lib/python3.10/dist-packages/invoke/tasks.py", line 138, in __call__
    result = self.body(*args, **kwargs)
  File "/home/wger/src/wger/tasks.py", line 82, in bootstrap
    create_settings(context, settings_path=settings_path, database_path=database_path)
  File "/usr/local/lib/python3.10/dist-packages/invoke/tasks.py", line 138, in __call__
    result = self.body(*args, **kwargs)
  File "/home/wger/src/wger/tasks.py", line 171, in create_settings
    with open(settings_path, 'w') as settings_file:
PermissionError: [Errno 13] Permission denied: '/home/wger/src/settings.py'
Traceback (most recent call last):
  File "/home/wger/.local/bin/wger", line 8, in <module>
    sys.exit(main())
  File "/home/wger/src/wger/__main__.py", line 40, in main
    run(invoke_cmd + ' '.join(args), pty=True)
  File "/usr/local/lib/python3.10/dist-packages/invoke/__init__.py", line 50, in run
    return Context().run(command, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/invoke/context.py", line 104, in run
    return self._run(runner, command, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/invoke/context.py", line 113, in _run
    return runner.run(command, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/invoke/runners.py", line 395, in run
    return self._run_body(command, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/invoke/runners.py", line 451, in _run_body
    return self.make_promise() if self._asynchronous else self._finish()
  File "/usr/local/lib/python3.10/dist-packages/invoke/runners.py", line 518, in _finish
    raise UnexpectedExit(result)
invoke.exceptions.UnexpectedExit: Encountered a bad command exit code!

Command: 'invoke bootstrap'

Exit code: 1

Stdout: already printed

Stderr: n/a (PTYs have no stderr)


Traceback (most recent call last):
  File "/home/wger/src/manage.py", line 19, in <module>
    setup_django_environment(get_path('settings.py'))
  File "/home/wger/src/wger/tasks.py", line 337, in setup_django_environment
    django.setup()
  File "/usr/local/lib/python3.10/dist-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 102, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 89, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 217, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'settings'
Using django's development server...
Traceback (most recent call last):
  File "/home/wger/src/manage.py", line 19, in <module>
    setup_django_environment(get_path('settings.py'))
  File "/home/wger/src/wger/tasks.py", line 337, in setup_django_environment
    django.setup()
  File "/usr/local/lib/python3.10/dist-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 102, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 89, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python3.10/dist-packages/django/conf/__init__.py", line 217, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'settings'

@Dieterbe Dieterbe reopened this May 4, 2024
@Dieterbe
Copy link
Contributor

Dieterbe commented May 4, 2024

The issue is due to this flag when running the container:

-v /path/to/this/checkout:/home/wger/src

inside the container, wger has user ID 1000.
when you mount a volume, it'll user whatever user id's and group id's you use on the host.
in my case, those are 1011 because that's my user ID, so inside the container, the wger user has no permission
(even though when the image was built, we chown'd to wger, but then we mount the volume over it)

@Dieterbe
Copy link
Contributor

after some experimentation, i realized it would be a lot of work to try to cleanly support the use case of a different user ID, and since no one else is dealing with this, i just changed my own UID on my host to 1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants