client: lib_docker: append custom Dockerfile to final Dockerfile
This commit is contained in:
@@ -53,12 +53,12 @@ fi
|
||||
function lib_docker::__docker_compose()
|
||||
{
|
||||
[ -z "$global_env_file" ] && lib_utils::die_fatal
|
||||
[ -z "$global_dockerfile_path" ] && lib_utils::die_fatal
|
||||
[ -z "$global_repo_dockerfiles" ] && lib_utils::die_fatal
|
||||
|
||||
[ ! -f "$global_env_file" ] \
|
||||
&& lib_utils::die_fatal "$global_env_file not found! Run the gen command!"
|
||||
|
||||
pushd "$global_dockerfile_path" 1>/dev/null \
|
||||
pushd "$global_repo_dockerfiles" 1>/dev/null \
|
||||
|| return $? \
|
||||
&& docker compose -f docker-compose.yml --env-file "$global_env_file" "$@"
|
||||
popd 1>/dev/null || return $?
|
||||
|
||||
@@ -109,15 +109,18 @@ function lib_docker::docker()
|
||||
# Setup remaining client/container globals
|
||||
lib_gen::gen || return $?
|
||||
|
||||
# TODO: all following docker related should be internal
|
||||
|
||||
# Docker-related files
|
||||
[ -z "$global_repo_client" ] && lib_utils::die_fatal
|
||||
declare -g global_dockerfile_path="${global_repo_client}/Dockerfiles/"
|
||||
declare -g global_repo_dockerfiles="${global_repo_client}/Dockerfiles/"
|
||||
|
||||
case "$global_platform" in
|
||||
archlinux | ubuntu)
|
||||
global_dockerfile_path+="finance"
|
||||
global_repo_dockerfiles+="finance"
|
||||
;;
|
||||
dev-tools)
|
||||
global_dockerfile_path+="dev-tools"
|
||||
global_repo_dockerfiles+="dev-tools"
|
||||
;;
|
||||
*)
|
||||
lib_utils::die_fatal "platform was not previously checked"
|
||||
@@ -131,7 +134,7 @@ function lib_docker::docker()
|
||||
[ -z "$global_env_file" ] && lib_utils::die_fatal
|
||||
[ -z "$global_shell_file" ] && lib_utils::die_fatal
|
||||
|
||||
local _path="${global_dockerfile_path}/docker-compose.yml"
|
||||
local _path="${global_repo_dockerfiles}/docker-compose.yml"
|
||||
lib_utils::print_debug "Generating '${_path}'"
|
||||
|
||||
sed \
|
||||
@@ -148,7 +151,7 @@ function lib_docker::docker()
|
||||
[ -z "$DOCKER_FINANCE_GID" ] && lib_utils::die_fatal
|
||||
[ -z "$DOCKER_FINANCE_USER" ] && lib_utils::die_fatal
|
||||
|
||||
local _path="${global_dockerfile_path}/Dockerfile"
|
||||
local _path="${global_repo_dockerfiles}/Dockerfile"
|
||||
lib_utils::print_debug "Generating '${_path}'"
|
||||
|
||||
sed \
|
||||
@@ -157,6 +160,19 @@ function lib_docker::docker()
|
||||
-e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
|
||||
"${_path}.${global_platform}.in" >"$_path" || return $?
|
||||
|
||||
# Append end-user's custom Dockerfile to final Dockerfile
|
||||
[ -z "$global_custom_dockerfile" ] && lib_utils::die_fatal
|
||||
|
||||
if [[ ! -f "$global_custom_dockerfile" ]]; then
|
||||
lib_utils::print_debug "'${global_custom_dockerfile}' not found, skipping"
|
||||
return 0
|
||||
fi
|
||||
|
||||
lib_utils::print_debug "Appending '${global_custom_dockerfile}' to '${_path}'"
|
||||
sed \
|
||||
-e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
|
||||
"$global_custom_dockerfile" >>"$_path" || return $?
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user