mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
armbian-next: docker: handle the case where we can't pull, and don't otherwise have, the base image; in this case use original debian/ubuntu image
This commit is contained in:
@@ -84,9 +84,13 @@ function docker_cli_prepare() {
|
||||
#declare -g DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE:-"debian:bookworm"}" # works Linux & Darwin
|
||||
#declare -g DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE:-"debian:sid"}" # works Linux & Darwin
|
||||
#declare -g DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE:-"debian:bullseye"}" # does NOT work under Darwin? loop problems.
|
||||
#declare -g DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE:-"ubuntu:kinetic"}" # works Linux & Darwin
|
||||
declare -g DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE:-"ubuntu:jammy"}" # works Linux & Darwin
|
||||
declare -g DOCKER_ARMBIAN_TARGET_PATH="${DOCKER_ARMBIAN_TARGET_PATH:-"/armbian"}"
|
||||
|
||||
# Store the "from scratch" image. Will be used if Armbian image is not available, for a "from scratch" build.
|
||||
declare -g DOCKER_ARMBIAN_BASE_IMAGE_SCRATCH="${DOCKER_ARMBIAN_BASE_IMAGE}"
|
||||
|
||||
# If we're NOT building the public, official image, then USE the public, official image as base.
|
||||
# IMPORTANT: This has to match the naming scheme for tag the is used in the GitHub actions workflow.
|
||||
if [[ "${DOCKERFILE_USE_ARMBIAN_IMAGE_AS_BASE}" != "no" ]]; then
|
||||
@@ -197,7 +201,7 @@ function docker_cli_prepare() {
|
||||
**/.DS_Store
|
||||
DOCKERIGNORE
|
||||
|
||||
display_alert "Creating" "Dockerfile" "info"
|
||||
display_alert "Creating" "Dockerfile; FROM ${DOCKER_ARMBIAN_BASE_IMAGE}" "info"
|
||||
cat <<- INITIAL_DOCKERFILE > "${SRC}"/Dockerfile
|
||||
FROM ${DOCKER_ARMBIAN_BASE_IMAGE}
|
||||
# PLEASE DO NOT MODIFY THIS FILE. IT IS AUTOGENERATED AND WILL BE OVERWRITTEN. Please don't build this Dockerfile yourself either. Use Armbian helpers instead.
|
||||
@@ -242,11 +246,26 @@ function docker_cli_build_dockerfile() {
|
||||
|
||||
if [[ "${do_force_pull:-yes}" == "yes" ]]; then
|
||||
display_alert "Pulling" "${DOCKER_ARMBIAN_BASE_IMAGE}" "info"
|
||||
run_host_command_logged docker pull "${DOCKER_ARMBIAN_BASE_IMAGE}"
|
||||
local_image_sha="$(docker images --no-trunc --quiet "${DOCKER_ARMBIAN_BASE_IMAGE}")"
|
||||
display_alert "New local image sha after pull" "local_image_sha: ${local_image_sha}" "debug"
|
||||
# print current date and time in epoch format; touches mtime of file
|
||||
echo "${DOCKER_ARMBIAN_BASE_IMAGE}|${local_image_sha}|$(date +%s)" >> "${SRC}"/cache/docker/last-pull
|
||||
local pull_failed="yes"
|
||||
run_host_command_logged docker pull "${DOCKER_ARMBIAN_BASE_IMAGE}" && pull_failed="no"
|
||||
|
||||
if [[ "${pull_failed}" == "no" ]]; then
|
||||
local_image_sha="$(docker images --no-trunc --quiet "${DOCKER_ARMBIAN_BASE_IMAGE}")"
|
||||
display_alert "New local image sha after pull" "local_image_sha: ${local_image_sha}" "debug"
|
||||
# print current date and time in epoch format; touches mtime of file
|
||||
echo "${DOCKER_ARMBIAN_BASE_IMAGE}|${local_image_sha}|$(date +%s)" >> "${SRC}"/cache/docker/last-pull
|
||||
else
|
||||
display_alert "Failed to pull" "${DOCKER_ARMBIAN_BASE_IMAGE}; will build from scratch instead" "wrn"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we get here without a local_image_sha, we need to build from scratch, so we need to re-create the Dockerfile.
|
||||
if [[ -z "${local_image_sha}" ]]; then
|
||||
display_alert "Base image not in local cache, building from scratch" "${DOCKER_ARMBIAN_BASE_IMAGE}" "info"
|
||||
export DOCKERFILE_USE_ARMBIAN_IMAGE_AS_BASE=no
|
||||
export DOCKER_ARMBIAN_BASE_IMAGE="${DOCKER_ARMBIAN_BASE_IMAGE_SCRATCH}"
|
||||
docker_cli_prepare
|
||||
display_alert "Re-created" "Dockerfile, proceeding, build from scratch" "debug"
|
||||
fi
|
||||
|
||||
display_alert "Building" "Dockerfile via '${DOCKER_BUILDX_OR_BUILD[*]}'" "info"
|
||||
@@ -341,7 +360,7 @@ function docker_cli_launch() {
|
||||
|
||||
display_alert "Relaunching in Docker" "${*}" "debug"
|
||||
display_alert "Relaunching in Docker" "here comes the 🐳" "info"
|
||||
|
||||
|
||||
local -i docker_build_result=1
|
||||
if docker run -it "${DOCKER_ARGS[@]}" "${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG}" /bin/bash "${DOCKER_ARMBIAN_TARGET_PATH}/compile.sh" "$@"; then
|
||||
display_alert "Docker Build finished" "successfully" "info"
|
||||
|
||||
Reference in New Issue
Block a user