armbian-next: python/pip: include pip pkgs in Dockerfile; use them if available instead of downloading
This commit is contained in:
parent
03dd0d623b
commit
399d9964dd
@ -22,11 +22,14 @@ function cli_requirements_run() {
|
||||
host_release="${HOSTRELEASE}" host_arch="${HOSTARCH}" early_prepare_host_dependencies
|
||||
|
||||
LOG_SECTION="install_host_dependencies" do_with_logging install_host_dependencies "for requirements command"
|
||||
declare -i -g -r prepare_host_has_already_run=1 # global, readonly. fool the rest of the script into thinking we've already run prepare_host.
|
||||
|
||||
if [[ "${ARMBIAN_INSIDE_DOCKERFILE_BUILD}" == "yes" ]]; then
|
||||
# Include python/pip packages in the Dockerfile build.
|
||||
deploy_to_non_cache_dir="yes" prepare_python_and_pip
|
||||
|
||||
# During the Dockerfile build, we want to pre-download ORAS/shellcheck/shfmt so it's included in the image.
|
||||
# We need to change the deployment directory to something not in ./cache, so it's baked into the image.
|
||||
|
||||
deploy_to_non_cache_dir="yes" run_tool_oras # download-only, to non-cache dir.
|
||||
deploy_to_non_cache_dir="yes" run_tool_shellcheck # download-only, to non-cache dir.
|
||||
|
||||
|
||||
@ -55,11 +55,24 @@ function prepare_python_and_pip() {
|
||||
early_prepare_pip3_dependencies_for_python_tools
|
||||
python3_pip_dependencies_hash="$(echo "${HOSTRELEASE}" "${python3_version}" "${pip3_version}" "${python3_pip_dependencies[*]}" | sha256sum | cut -d' ' -f1)"
|
||||
|
||||
declare non_cache_dir="/armbian-pip"
|
||||
declare python_pip_cache="${SRC}/cache/pip"
|
||||
|
||||
if [[ "${deploy_to_non_cache_dir:-"no"}" == "yes" ]]; then
|
||||
display_alert "Using non-cache dir" "PIP: ${non_cache_dir}" "warn"
|
||||
python_pip_cache="${non_cache_dir}"
|
||||
else
|
||||
# if the non-cache dir exists, copy it into place, if not already existing...
|
||||
if [[ -d "${non_cache_dir}" && ! -d "${python_pip_cache}" ]]; then
|
||||
display_alert "Deploying pip cache from Docker image" "${non_cache_dir} -> ${python_pip_cache}" "info"
|
||||
run_host_command_logged cp -pr "${non_cache_dir}" "${python_pip_cache}"
|
||||
fi
|
||||
fi
|
||||
|
||||
declare python_hash_base="${python_pip_cache}/pip_pkg_hash"
|
||||
declare python_hash_file="${python_hash_base}_${python3_pip_dependencies_hash}"
|
||||
declare python3_user_base="${SRC}/cache/pip/base"
|
||||
declare python3_pycache="${SRC}/cache/pip/pycache"
|
||||
declare python3_user_base="${python_pip_cache}/base"
|
||||
declare python3_pycache="${python_pip_cache}/pycache"
|
||||
|
||||
# declare a readonly global dict with all needed info for executing stuff using this setup
|
||||
declare -r -g -A PYTHON3_INFO=(
|
||||
|
||||
@ -251,11 +251,19 @@ function docker_cli_prepare_dockerfile() {
|
||||
|
||||
# This includes apt install equivalent to install_host_dependencies()
|
||||
display_alert "Creating" "Dockerfile; FROM ${DOCKER_ARMBIAN_BASE_IMAGE}" "info"
|
||||
|
||||
declare c="" # Nothing; commands will run.
|
||||
if [[ "${DOCKER_SIMULATE_CLEAN}" == "yes" ]]; then
|
||||
display_alert "Simulating" "clean build, due to DOCKER_SIMULATE_CLEAN=yes -- this is wasteful and slow and only for debugging" "warn"
|
||||
c="## " # Add comment to simulate clean env
|
||||
fi
|
||||
|
||||
declare c_req="# " # Nothing; commands will run.
|
||||
if [[ "${DOCKERFILE_USE_ARMBIAN_IMAGE_AS_BASE}" == "no" ]]; then
|
||||
display_alert "Dockerfile build will include tooling/requirements" "due to DOCKERFILE_USE_ARMBIAN_IMAGE_AS_BASE=no" "info"
|
||||
c_req=""
|
||||
fi
|
||||
|
||||
cat <<- INITIAL_DOCKERFILE > "${SRC}"/Dockerfile
|
||||
${c}# PLEASE DO NOT MODIFY THIS FILE. IT IS AUTOGENERATED AND WILL BE OVERWRITTEN. Please don't build this Dockerfile yourself either. Use Armbian ./compile.sh instead.
|
||||
FROM ${DOCKER_ARMBIAN_BASE_IMAGE}
|
||||
@ -268,9 +276,9 @@ function docker_cli_prepare_dockerfile() {
|
||||
WORKDIR ${DOCKER_ARMBIAN_TARGET_PATH}
|
||||
ENV ARMBIAN_RUNNING_IN_CONTAINER=yes
|
||||
ADD . ${DOCKER_ARMBIAN_TARGET_PATH}/
|
||||
${c}RUN echo "--> CACHE MISS IN DOCKERFILE: running Armbian requirements initialization." && \\
|
||||
${c} ARMBIAN_INSIDE_DOCKERFILE_BUILD="yes" /bin/bash "${DOCKER_ARMBIAN_TARGET_PATH}/compile.sh" requirements SHOW_LOG=yes && \\
|
||||
${c} rm -rf "${DOCKER_ARMBIAN_TARGET_PATH}/output" "${DOCKER_ARMBIAN_TARGET_PATH}/.tmp" "${DOCKER_ARMBIAN_TARGET_PATH}/cache"
|
||||
${c}${c_req}RUN echo "--> CACHE MISS IN DOCKERFILE: running Armbian requirements initialization." && \\
|
||||
${c}${c_req} ARMBIAN_INSIDE_DOCKERFILE_BUILD="yes" /bin/bash "${DOCKER_ARMBIAN_TARGET_PATH}/compile.sh" requirements SHOW_LOG=yes && \\
|
||||
${c}${c_req} rm -rf "${DOCKER_ARMBIAN_TARGET_PATH}/output" "${DOCKER_ARMBIAN_TARGET_PATH}/.tmp" "${DOCKER_ARMBIAN_TARGET_PATH}/cache"
|
||||
${include_dot_git_dir}
|
||||
INITIAL_DOCKERFILE
|
||||
# For debugging: RUN rm -fv /usr/bin/pip3 # Remove pip3 symlink to make sure we're not depending on it; non-Dockers may not have it
|
||||
|
||||
Loading…
Reference in New Issue
Block a user