azerothcore-wotlk icon indicating copy to clipboard operation
azerothcore-wotlk copied to clipboard

fix(Docker): Check write access for config dir

Open michaeldelago opened this issue 1 year ago • 0 comments

Changes Proposed:

This makes it so the startup script (known as the entrypoint) for the docker containers will ensure that it owns the config and filelog directories on startup.

This is important since there's the dist config files that get created during build, and these need to be transferred to the runtime config directory at runtime if they don't exist already.

Technically speaking, we could remove the bind mount (actually comment it out in the docker-compose.yaml file) so that the reader can see there's an option to do so. The reasoning for this is to nudge the user in the direction of using environment variables for config rather than files. On the other hand, this breaks compatibility for other users and we don't really need to do that for something so small.

Issues Addressed:

  • https://github.com/azerothcore/azerothcore-wotlk/issues/17656
    • It's common for users to clone the repo as root, which makes the config directories owned to root.
    • This is problematic because the servers for azerothcore run as non-root by default
    • As noted, the startup process creates files in the config dir, and a non-root user can't do that in a directory where they don't have write access
    • All in all this results in a somewhat confusing output on exit. It's a somewhat common thing to support.

Tests Performed:

This PR has been:

  • [x] Tested in-game by the author.
  • [ ] Tested in-game by other community members/someone else other than the author/has been live on production servers.
  • [ ] This pull request requires further testing and may have edge cases to be tested.

How to Test the Changes:

  1. run command sudo chown -R 0:0 env/dist so its all owned to root
  2. run docker compose up --build ac-db-import to build and run the db import. it should fail, with a big warning message at the top describing the error and possible resolution
  3. run sudo chown -R 1000:1000 env/dist so it's owned to the default acore user
  4. run docker compose up --build ac-db-import, it should build and start like normal

How to Test AzerothCore PRs

When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].

You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:

http://www.azerothcore.org/wiki/How-to-test-a-PR

REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).

For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.

michaeldelago avatar Jan 29 '24 00:01 michaeldelago