Fix configs in docker builds (#14747)
<!-- First of all, THANK YOU for your contribution. --> ## Changes Proposed - This fixes an issue where the .conf files aren't properly generated for the docker build - With this issue, the dbimport service in the docker compose file would fail to start due to insufficient config. - related to PR #14707 - create a ".user" file extension for custom configs in `env/docker/etc/` - Layers the ".dockerdist" file and the ".user" file over the ".dist" file (in that order), and then copies the ".dist" file to the base ".conf" file - Docker specific config changes go in the ".dockerdist" file and should still be committed to the repo - User specific config changes go in ".user" file and should not be committed to the repo - If the ".dist" file and the base ".conf" file are different, the ".conf" will be backed up before the ".dist" file is copied into it ## Issues Addressed: <!-- If your fix has a relating issue, link it below --> - There isn't a specific issue, however this was reported and discussed in discord over the course of yesterday and today ## SOURCE: <!-- If you can, include a source that can strengthen your claim --> ## Tests Performed: <!-- Does it build without errors? Did you test in-game? What did you test? On which OS did you test? Describe any other tests performed --> - Executing commands to build and start the game server - after creating an account, I can log in and play without any issues. ## How to Test the Changes: <!-- Describe in a detailed step-by-step order how to test the changes --> 1. Execute commands ```bash $ ./acore.sh docker clean:build && ./acore.sh docker build:nocache && ./acore.sh docker start:app ``` 2. Create account and log in as normal ## Known Issues and TODO List: <!-- Is there anything else left to do after this PR? --> - The largest issue that comes to mind is this is a breaking change for docker users (though, so was the change that caused this) - Docker users (and nobody else, of course) can no longer use the ".conf" for custom changes in docker setups. - Their custom changes will have to be migrated to the ".user" file - Since the old ".conf" file is backed up, users should have minimal trouble copying the changes in the old ".conf" file to the new ".user" file <!-- If you intend to contribute repeatedly to our project, it is a good idea to join our discord channel. We set ranks for our contributors and give them access to special resources or knowledge: https://discord.com/invite/DasJqPba) Do not remove the instructions below about testing, they will help users to test your PR --> ## 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**. edit: link related PR
This commit is contained in:
parent
437d93926f
commit
888a718cf3
4
.gitignore
vendored
4
.gitignore
vendored
@ -22,9 +22,7 @@
|
||||
!/env/docker/data/.gitkeep
|
||||
!/env/docker/etc/
|
||||
/env/docker/etc/*
|
||||
!/env/docker/etc/authserver.conf.dockerdist
|
||||
!/env/docker/etc/worldserver.conf.dockerdist
|
||||
!/env/docker/etc/dbimport.conf.dockerdist
|
||||
!/env/docker/etc/*.conf.dockerdist
|
||||
!/env/docker/logs/.gitkeep
|
||||
/.env*
|
||||
/apps/joiner
|
||||
|
||||
@ -104,9 +104,7 @@ function comp_compile() {
|
||||
|
||||
echo "Using $MTHREADS threads"
|
||||
|
||||
CWD=$(pwd)
|
||||
|
||||
cd $BUILDPATH
|
||||
pushd "$BUILDPATH" >> /dev/null || exit 1
|
||||
|
||||
comp_ccacheEnable
|
||||
|
||||
@ -121,7 +119,7 @@ function comp_compile() {
|
||||
msys*)
|
||||
cmake --install . --config $CTYPE
|
||||
|
||||
cd $CWD
|
||||
popd >> /dev/null || exit 1
|
||||
|
||||
echo "Done"
|
||||
;;
|
||||
@ -138,7 +136,7 @@ function comp_compile() {
|
||||
echo "Cmake install..."
|
||||
sudo cmake --install . --config $CTYPE
|
||||
|
||||
cd $CWD
|
||||
popd >> /dev/null || exit 1
|
||||
|
||||
# set all aplications SUID bit
|
||||
echo "Setting permissions on binary files"
|
||||
@ -149,13 +147,16 @@ function comp_compile() {
|
||||
|
||||
if [[ $DOCKER = 1 && $DISABLE_DOCKER_CONF != 1 ]]; then
|
||||
echo "Generating confs..."
|
||||
cp -n "$DOCKER_ETC_FOLDER/worldserver.conf.dockerdist" "${confDir}/worldserver.conf"
|
||||
cp -n "$DOCKER_ETC_FOLDER/authserver.conf.dockerdist" "${confDir}/authserver.conf"
|
||||
cp -n "$DOCKER_ETC_FOLDER/dbimport.conf.dockerdist" "${confDir}/dbimport.conf"
|
||||
for dockerdist in "$DOCKER_ETC_FOLDER"/*.dockerdist; do
|
||||
base_conf="$(echo "$dockerdist" | rev | cut -f1 -d. --complement | rev)"
|
||||
cp -nv "$base_conf.dist" "$base_conf"
|
||||
# Move configs from .conf.dockerdist to .conf
|
||||
conf_layer "$dockerdist" "$base_conf" " # Copied from dockerdist"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Done"
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
|
||||
runHooks "ON_AFTER_BUILD"
|
||||
@ -170,3 +171,31 @@ function comp_all() {
|
||||
comp_clean
|
||||
comp_build
|
||||
}
|
||||
|
||||
# conf_layer FILENAME FILENAME
|
||||
# Layer the configuration parameters from the first argument onto the second argument
|
||||
function conf_layer() {
|
||||
LAYER="$1"
|
||||
BASE="$2"
|
||||
COMMENT="$3"
|
||||
|
||||
grep -E "^[a-zA-Z\.0-9]+\s*=.*$" "$LAYER" \
|
||||
| while read -r param
|
||||
do
|
||||
NOSPACE="$(tr -d '[:space:]' <<< "$param")"
|
||||
KEY="$(cut -f1 -d= <<< "$NOSPACE")"
|
||||
VAL="$(cut -f2 -d= <<< "$NOSPACE")"
|
||||
# if key not in base or val not in line
|
||||
if grep -qE "^$KEY" "$BASE" && ! grep -qE "^$KEY.*=.*$VAL" "$BASE"; then
|
||||
# Replace line
|
||||
# Prevent issues with shell quoting
|
||||
sed -i \
|
||||
's,^'"$KEY"'.*,'"$KEY = $VAL$COMMENT"',g' \
|
||||
"$BASE"
|
||||
else
|
||||
# insert line
|
||||
echo "$KEY = $VAL$COMMENT" >> "$BASE"
|
||||
fi
|
||||
done
|
||||
echo "Layered $LAYER onto $BASE"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user