feat(Apps/Docker): Use Env Vars for docker configuration (#17040)

* feat(docker): Use Env Vars for docker configuration

use env vars for docker

* simplify docker-compose.yaml
This commit is contained in:
Mike Delago 2023-08-20 11:52:38 -04:00 committed by GitHub
parent 5367eb4b1d
commit f241a6e352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 60 additions and 185 deletions

View File

@ -6,15 +6,6 @@
/env/dist/*
!/env/dist/.gitkeep
/env/user/*
/env/docker/*
!/env/docker/bin/.gitkeep
!/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/logs/.gitkeep
/.env*
.idea
!.gitkeep

7
.gitignore vendored
View File

@ -17,13 +17,6 @@
/env/dist/*
!/env/dist/.gitkeep
/env/user/*
/env/docker/*
!/env/docker/bin/.gitkeep
!/env/docker/data/.gitkeep
!/env/docker/etc/
/env/docker/etc/*
!/env/docker/etc/*.conf.dockerdist
!/env/docker/logs/.gitkeep
/.env*
/apps/joiner
/deps/deno

View File

@ -143,32 +143,6 @@ function comp_compile() {
find "$AC_BINPATH_FULL" -mindepth 1 -maxdepth 1 -type f -exec sudo chown root:root -- {} +
find "$AC_BINPATH_FULL" -mindepth 1 -maxdepth 1 -type f -exec sudo chmod u+s -- {} +
DOCKER_ETC_FOLDER=${DOCKER_ETC_FOLDER:-"env/dist/etc"}
if [[ $DOCKER = 1 && $DISABLE_DOCKER_CONF != 1 ]]; then
echo "Generating confs..."
# Search for all configs under DOCKER_ETC_FOLDER
for dockerdist in "$DOCKER_ETC_FOLDER"/*.dockerdist; do
# Grab "base" conf. turns foo.conf.dockerdist into foo.conf
baseConf="$(echo "$dockerdist" | rev | cut -f1 -d. --complement | rev)"
# env/dist/etc/foo.conf becomes foo.conf
filename="$(basename "$baseConf")"
# the dist files should be always found inside $confDir
# which may not be the same as DOCKER_ETC_FOLDER
distPath="$confDir/$filename.dist"
# if dist file doesn't exist, skip this iteration
[ ! -f "$distPath" ] && continue
# replace params in foo.conf.dist with params in foo.conf.dockerdist
conf_layer "$dockerdist" "$distPath" " # Copied from dockerdist"
# Copy modified dist file to $confDir/$filename
# Don't overwrite foo.conf if it already exists.
cp --no-clobber --verbose "$distPath" "$confDir/$filename"
done
fi
echo "Done"
;;
esac
@ -185,36 +159,3 @@ 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"
# Loop over all defined params in conf file
grep -E "^[a-zA-Z\.0-9]+\s*=.*$" "$LAYER" \
| while read -r param
do
# remove spaces from param
# foo = bar becomes foo=bar
NOSPACE="$(tr -d '[:space:]' <<< "$param")"
# split into key and value
KEY="$(cut -f1 -d= <<< "$NOSPACE")"
VAL="$(cut -f2 -d= <<< "$NOSPACE")"
# if key in base and 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"
}

View File

@ -100,11 +100,6 @@ USER $DOCKER_USER
# NOTE: this folder is different by the /azerothcore (which is binded instead)
COPY --chown=$DOCKER_USER:$DOCKER_USER . /azerothcore
# Needed if we use the dev image without linking any external folder (e.g. acore-docker)
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/authserver.conf.dockerdist /azerothcore/env/dist/etc/authserver.conf.dockerdist
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/worldserver.conf.dockerdist /azerothcore/env/dist/etc/worldserver.conf.dockerdist
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/dbimport.conf.dockerdist /azerothcore/env/dist/etc/dbimport.conf.dockerdist
#================================================================
#
# SERVICE BASE: prepare the OS for the production-ready services
@ -211,9 +206,6 @@ COPY --chown=$DOCKER_USER:$DOCKER_USER ./modules /azerothcore/modules
# check if we have ccache files available outside
RUN rm -rf /azerothcore/var/ccache/*
COPY --chown=$DOCKER_USER:$DOCKER_USER var/docker/ccache /azerothcore/var/ccache
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/authserver.conf.dockerdist /azerothcore/env/dist/etc/authserver.conf.dockerdist
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/worldserver.conf.dockerdist /azerothcore/env/dist/etc/worldserver.conf.dockerdist
COPY --chown=$DOCKER_USER:$DOCKER_USER env/docker/etc/dbimport.conf.dockerdist /azerothcore/env/dist/etc/dbimport.conf.dockerdist
# install eluna
RUN git clone --depth=1 --branch=master https://github.com/azerothcore/mod-eluna.git /azerothcore/modules/mod-eluna

View File

@ -9,11 +9,7 @@ DOCKER_VOL_ROOT=
DOCKER_VOL_CONF=
DOCKER_VOL_ETC=
DOCKER_VOL_LOGS=
DOCKER_VOL_DATA_CAMERAS=
DOCKER_VOL_DATA_DBC=
DOCKER_VOL_DATA_MAPS=
DOCKER_VOL_DATA_VMAPS=
DOCKER_VOL_DATA_MMAPS=
DOCKER_VOL_DATA=
DOCKER_WORLD_EXTERNAL_PORT=
DOCKER_SOAP_EXTERNAL_PORT=

View File

@ -33,9 +33,9 @@ x-ac-service-conf: &ac-service-conf
<<: *ac-shared-conf
# List can't be merged. See: https://forums.docker.com/t/how-to-merge-a-list-of-volumes-from-an-extension-field-into-the-service-definition/77454
# volumes:
# - ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
# - ${DOCKER_VOL_ETC:-./env/dist/etc}:/azerothcore/env/dist/etc
# # [osxfs optimization]: https://stackoverflow.com/a/63437557/1964544
# - ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
# - ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
services:
@ -94,7 +94,7 @@ services:
# expose some dist folder outside allowing the host to use them
- ${DOCKER_VOL_CONF:-./conf}:/azerothcore/conf
- ${DOCKER_VOL_BIN:-ac-bin-dev}:/azerothcore/env/dist/bin
- ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
- ${DOCKER_VOL_ETC:-./env/dist/etc}:/azerothcore/env/dist/etc
- ac-build-dev:/azerothcore/var/build
- ac-ccache-dev:/azerothcore/var/ccache
profiles: [dev-build]
@ -118,32 +118,22 @@ services:
- seccomp:unconfined
env_file:
${DOCKER_AC_ENV_FILE:-conf/dist/env.ac}
environment:
AC_DATA_DIR: "/azerothcore/env/dist/data"
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_WORLD_DATABASE_INFO: "ac-database;3306;root;password;acore_world"
AC_CHARACTER_DATABASE_INFO: "ac-database;3306;root;password;acore_characters"
AC_CLOSE_IDLE_CONNECTIONS: "0"
ports:
- ${DOCKER_AUTH_EXTERNAL_PORT:-3724}:3724
- ${DOCKER_WORLD_EXTERNAL_PORT:-8085}:8085
- ${DOCKER_SOAP_EXTERNAL_PORT:-7878}:7878
volumes:
- ${DOCKER_VOL_ROOT:-.}:/azerothcore:cached
# expose some dist folder outside allowing the host to use them
- ${DOCKER_VOL_CONF:-./conf}:/azerothcore/conf
- ${DOCKER_VOL_BIN:-ac-bin-dev}:/azerothcore/env/dist/bin
- ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
# [osxfs optimization]: https://stackoverflow.com/a/63437557/1964544
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ac-build-dev:/azerothcore/var/build
- ac-ccache-dev:/azerothcore/var/ccache
# client data
- ${DOCKER_VOL_DATA_CAMERAS:-./env/docker/data/Cameras}:/azerothcore/env/dist/data/Cameras
- ${DOCKER_VOL_DATA_DBC:-./env/docker/data/dbc}:/azerothcore/env/dist/data/dbc
- ${DOCKER_VOL_DATA_MAPS:-./env/docker/data/maps}:/azerothcore/env/dist/data/maps
- ${DOCKER_VOL_DATA_VMAPS:-./env/docker/data/vmaps}:/azerothcore/env/dist/data/vmaps
- ${DOCKER_VOL_DATA_MMAPS:-./env/docker/data/mmaps}:/azerothcore/env/dist/data/mmaps
# remount again for the extractors
- ${DOCKER_VOL_DATA_CAMERAS:-./env/docker/data/Cameras}:/azerothcore/env/dist/bin/Cameras
- ${DOCKER_VOL_DATA_DBC:-./env/docker/data/dbc}:/azerothcore/env/dist/bin/dbc
- ${DOCKER_VOL_DATA_MAPS:-./env/docker/data/maps}:/azerothcore/env/dist/bin/maps
- ${DOCKER_VOL_DATA_VMAPS:-./env/docker/data/vmaps}:/azerothcore/env/dist/bin/vmaps
- ${DOCKER_VOL_DATA_MMAPS:-./env/docker/data/mmaps}:/azerothcore/env/dist/bin/mmaps
# this is not the directory of the extracted data! It's the client folder used by the extractors
- ${DOCKER_AC_CLIENT_FOLDER:-./var/client}:/azerothcore/env/dist/bin/Data
profiles: [dev]
@ -155,12 +145,19 @@ services:
<<: *ac-shared-conf
image: acore/ac-wotlk-worldserver-local:${DOCKER_IMAGE_TAG:-master} # name of the generated image after built locally
command: ./env/dist/bin/dbimport
environment:
AC_DATA_DIR: "/azerothcore/env/dist/data"
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_WORLD_DATABASE_INFO: "ac-database;3306;root;password;acore_world"
AC_CHARACTER_DATABASE_INFO: "ac-database;3306;root;password;acore_characters"
AC_CLOSE_IDLE_CONNECTIONS: "0"
volumes:
# read-only binaries compiled by ac-dev-server
- ${DOCKER_VOL_BIN:-ac-bin-dev}:/azerothcore/env/dist/bin:ro
- ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
- ${DOCKER_VOL_ETC:-./env/dist/etc}:/azerothcore/env/dist/etc:ro
# [osxfs optimization]: https://stackoverflow.com/a/63437557/1964544
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
profiles: [local, app, db-import-local]
depends_on:
ac-database:
@ -183,6 +180,13 @@ services:
restart: unless-stopped
env_file:
${DOCKER_AC_ENV_FILE:-conf/dist/env.ac}
environment:
AC_DATA_DIR: "/azerothcore/env/dist/data"
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_WORLD_DATABASE_INFO: "ac-database;3306;root;password;acore_world"
AC_CHARACTER_DATABASE_INFO: "ac-database;3306;root;password;acore_characters"
AC_CLOSE_IDLE_CONNECTIONS: "0"
user: ${DOCKER_USER:-root}
privileged: true
build:
@ -194,15 +198,11 @@ services:
volumes:
# read-only binaries compiled by ac-dev-server
- ${DOCKER_VOL_BIN:-ac-bin-dev}:/azerothcore/env/dist/bin:ro
- ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
- ${DOCKER_VOL_ETC:-./env/dist/etc}:/azerothcore/env/dist/etc:ro
# [osxfs optimization]: https://stackoverflow.com/a/63437557/1964544
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
# client data
- ${DOCKER_VOL_DATA_CAMERAS:-./env/docker/data/Cameras}:/azerothcore/env/dist/data/Cameras
- ${DOCKER_VOL_DATA_DBC:-./env/docker/data/dbc}:/azerothcore/env/dist/data/dbc
- ${DOCKER_VOL_DATA_MAPS:-./env/docker/data/maps}:/azerothcore/env/dist/data/maps
- ${DOCKER_VOL_DATA_VMAPS:-./env/docker/data/vmaps}:/azerothcore/env/dist/data/vmaps
- ${DOCKER_VOL_DATA_MMAPS:-./env/docker/data/mmaps}:/azerothcore/env/dist/data/mmaps
- ${DOCKER_VOL_DATA:-./env/dist/data/}:/azerothcore/env/dist/data/
profiles: [local, app, worldserver]
depends_on:
ac-database:
@ -218,6 +218,12 @@ services:
restart: unless-stopped
env_file:
${DOCKER_AC_ENV_FILE:-conf/dist/env.ac}
environment:
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_TEMP_DIR: "/azerothcore/env/dist/temp"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_SQLDRIVER_LOG_FILE: "SQLDriver.log"
AC_SQLDRIVER_QUERY_LOGGING: "1"
user: ${DOCKER_USER:-root}
build:
target: authserver-local
@ -225,9 +231,9 @@ services:
volumes:
# read-only binaries compiled by ac-dev-server
- ${DOCKER_VOL_BIN:-ac-bin-dev}:/azerothcore/env/dist/bin:ro
- ${DOCKER_VOL_ETC:-./env/docker/etc}:/azerothcore/env/dist/etc
- ${DOCKER_VOL_ETC:-./env/dist/etc}:/azerothcore/env/dist/etc
# [osxfs optimization]: https://stackoverflow.com/a/63437557/1964544
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
ports:
- ${DOCKER_AUTH_EXTERNAL_PORT:-3724}:3724
profiles: [local, app, authserver]
@ -281,6 +287,13 @@ services:
restart: unless-stopped
env_file:
${DOCKER_AC_ENV_FILE:-conf/dist/env.ac}
environment:
AC_DATA_DIR: "/azerothcore/env/dist/data"
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_WORLD_DATABASE_INFO: "ac-database;3306;root;password;acore_world"
AC_CHARACTER_DATABASE_INFO: "ac-database;3306;root;password;acore_characters"
AC_CLOSE_IDLE_CONNECTIONS: "0"
user: ${DOCKER_USER:-root}
privileged: true
build:
@ -290,7 +303,7 @@ services:
- ${DOCKER_WORLD_EXTERNAL_PORT:-8085}:8085
- ${DOCKER_SOAP_EXTERNAL_PORT:-7878}:7878
volumes:
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_CLIENT_DATA_PROD:-ac-client-data-prod}:/azerothcore/env/dist/data:ro
profiles: [prod, prod-app, prod-worldserver]
depends_on:
@ -309,12 +322,18 @@ services:
restart: unless-stopped
env_file:
${DOCKER_AC_ENV_FILE:-conf/dist/env.ac}
environment:
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_TEMP_DIR: "/azerothcore/env/dist/temp"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_SQLDRIVER_LOG_FILE: "SQLDriver.log"
AC_SQLDRIVER_QUERY_LOGGING: "1"
user: ${DOCKER_USER:-root}
build:
target: authserver
<<: *build-params
volumes:
- ${DOCKER_VOL_LOGS:-./env/docker/logs}:/azerothcore/env/dist/logs:delegated
- ${DOCKER_VOL_LOGS:-./env/dist/logs}:/azerothcore/env/dist/logs:delegated
ports:
- ${DOCKER_AUTH_EXTERNAL_PORT:-3724}:3724
profiles: [prod, prod-app, prod-authserver]
@ -324,7 +343,6 @@ services:
ac-db-import-prod:
condition: service_completed_successfully
ac-client-data-init:
image: acore/ac-wotlk-client-data:${DOCKER_IMAGE_TAG:-master} # name of the generated image after built locally
user: ${DOCKER_USER:-root}
@ -356,6 +374,13 @@ services:
<<: *ac-shared-conf
image: acore/ac-wotlk-worldserver:${DOCKER_IMAGE_TAG:-master} # name of the generated image after built locally
command: ./env/dist/bin/dbimport
environment:
AC_DATA_DIR: "/azerothcore/env/dist/data"
AC_LOGS_DIR: "/azerothcore/env/dist/logs"
AC_LOGIN_DATABASE_INFO: "ac-database;3306;root;password;acore_auth"
AC_WORLD_DATABASE_INFO: "ac-database;3306;root;password;acore_world"
AC_CHARACTER_DATABASE_INFO: "ac-database;3306;root;password;acore_characters"
AC_CLOSE_IDLE_CONNECTIONS: "0"
profiles: [prod, prod-app, db-import-prod]
#

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -1,22 +0,0 @@
###############################################
# AzerothCore Auth Server configuration file #
###############################################
[authserver]
# Do not change this
# Files in LogsDir will reflect on your host directory: docker/authserver/logs
LogsDir = "/azerothcore/env/dist/logs"
# Files in TempDir will reflect on your host directory: docker/authserver/temp
TempDir = "/azerothcore/env/dist/temp"
# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth"
# Add more configuration overwrites by copying settings from from authserver.conf.dist
SQLDriverLogFile = "SQLDriver.log"
SQLDriverQueryLogging = 1

View File

@ -1,18 +0,0 @@
# Do NOT change those Dir configs
# Files in LogsDir will reflect on your host directory: docker/worldserver/logs
LogsDir = "/azerothcore/env/dist/logs"
# Files in TempDir will reflect on your host directory: docker/authserver/temp
DataDir = "/azerothcore/env/dist/data"
# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth"
WorldDatabaseInfo = "ac-database;3306;root;password;acore_world"
CharacterDatabaseInfo = "ac-database;3306;root;password;acore_characters"
# Add more configuration overwrites by copying settings from worldserver.conf.dist
# Disable idle connections automatic kick since it doesn't work well on macOS + Docker
CloseIdleConnections = 0

View File

@ -1,23 +0,0 @@
################################################
# AzerothCore World Server configuration file #
################################################
[worldserver]
# Do NOT change those Dir configs
# Files in LogsDir will reflect on your host directory: docker/worldserver/logs
LogsDir = "/azerothcore/env/dist/logs"
# Files in TempDir will reflect on your host directory: docker/authserver/temp
DataDir = "/azerothcore/env/dist/data"
# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth"
WorldDatabaseInfo = "ac-database;3306;root;password;acore_world"
CharacterDatabaseInfo = "ac-database;3306;root;password;acore_characters"
# Add more configuration overwrites by copying settings from worldserver.conf.dist
# Disable idle connections automatic kick since it doesn't work well on macOS + Docker
CloseIdleConnections = 0

View File