[2/3]: Enough to build images
* Push testing isnt done yet * Initial arm64 job has been done but not tested
This commit is contained in:
parent
c59dbe6812
commit
336dfb237e
@ -3,9 +3,8 @@
|
||||
|
||||
#### NOTE
|
||||
* This tool auto pushes all successful builds to docker.io
|
||||
* Only usable for X86_64 systems as of it's design
|
||||
|
||||
#### This tool is used for
|
||||
* AMD64 docker image builder
|
||||
* ARM64 docker image builder
|
||||
* AMD64 docker image builder + pushing
|
||||
* ARM64 docker image builder + pushing
|
||||
|
||||
|
20
build.sh
20
build.sh
@ -2,14 +2,6 @@
|
||||
|
||||
set -e -o pipefail -u
|
||||
|
||||
##
|
||||
# Export some needed things for head script to work with
|
||||
##
|
||||
|
||||
export SHOW_DEBUG=false
|
||||
export ROOT=$(pwd)
|
||||
export TMP=$ROOT/tmp
|
||||
|
||||
##
|
||||
# Source modules for functions
|
||||
##
|
||||
@ -18,6 +10,10 @@ export TMP=$ROOT/tmp
|
||||
source modules/cli_msg.sh
|
||||
loaded "CLI - Message types"
|
||||
|
||||
# Load variables/exports
|
||||
source modules/variables.sh
|
||||
loaded "EXPORT - Variables"
|
||||
|
||||
# TMP manager
|
||||
source modules/tmp_manager.sh
|
||||
loaded "TMP Manager"
|
||||
@ -38,12 +34,6 @@ loaded "CLI - Docker main functions for image building"
|
||||
# Trigger essential modules
|
||||
##
|
||||
|
||||
# Failsafe
|
||||
system_type=$(uname -m)
|
||||
if [ ! "${system_type}" = "x86_64" ]; then
|
||||
msg_error "This is only supported for X86_64 systems"
|
||||
fi
|
||||
|
||||
setup_tmp
|
||||
|
||||
msg_spacer
|
||||
@ -62,6 +52,8 @@ while (($# >= 1)); do
|
||||
-h|--help) show_help;;
|
||||
--amd64-image) build_amd64;;
|
||||
--arm64-image) build_arm64;;
|
||||
--amd64-push) push_amd64;;
|
||||
--arm64-push) push_arm64;;
|
||||
*) unknown_option ${1};;
|
||||
-*) unknown_option ${1};;
|
||||
--*) unknown_option ${1};;
|
||||
|
@ -3,6 +3,20 @@
|
||||
##
|
||||
|
||||
delete_existing() {
|
||||
docker rmi hilledkinged/evolinx -f
|
||||
# AMD64
|
||||
if [ "${ARCH}" = "amd64" ]; then
|
||||
sudo docker rmi hilledkinged/evolinx:latest -f
|
||||
fi
|
||||
|
||||
# ARM64
|
||||
if [ "${ARCH}" = "arm64" ]; then
|
||||
sudo docker rmi hilledkinged/evolinx:arm64 -f
|
||||
fi
|
||||
|
||||
message "Existing image removed"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
message "Starting docker service"
|
||||
sudo systemctl restart docker
|
||||
}
|
||||
|
@ -7,23 +7,50 @@ make_env () {
|
||||
}
|
||||
|
||||
cleanup_env() {
|
||||
message "Cleaning up environment"
|
||||
sudo rm -rf $TMP/rootfs
|
||||
}
|
||||
|
||||
strap_base() {
|
||||
sudo base-strap $TMP/rootfs base-chroot
|
||||
# AMD64
|
||||
if [ "${ARCH}" = "amd64" ]; then
|
||||
sudo base-strap $TMP/rootfs base-chroot
|
||||
fi
|
||||
|
||||
# ARM64
|
||||
if [ "${ARCH}" = "arm64" ]; then
|
||||
sudo base-strap $TMP/rootfs base-chroot
|
||||
fi
|
||||
}
|
||||
|
||||
rootfs_to_image() {
|
||||
cd $TMP && sudo tar -C rootfs -c . | sudo docker import - hilledkinged/evolinx
|
||||
# AMD64
|
||||
if [ "${ARCH}" = "amd64" ]; then
|
||||
cd $TMP && sudo tar -C rootfs -c . | sudo docker import - hilledkinged/evolinx:latest
|
||||
fi
|
||||
|
||||
# ARM64
|
||||
if [ "${ARCH}" = "arm64" ]; then
|
||||
cd $TMP && sudo tar -C rootfs -c . | sudo docker import - hilledkinged/evolinx:arm64
|
||||
fi
|
||||
}
|
||||
|
||||
push_image() {
|
||||
if [ ]; then
|
||||
sudo docker image push hilledkinged/evolinx:latest
|
||||
amd64_push() {
|
||||
# AMD64
|
||||
if [ "${ARCH}" = "amd64" ]; then
|
||||
sudo docker image push hilledkinged/evolinx:latest
|
||||
fi
|
||||
|
||||
# ARM64
|
||||
if [ "${ARCH}" = "arm64" ]; then
|
||||
sudo docker image push hilledkinged/evolinx:arm64
|
||||
fi
|
||||
}
|
||||
|
||||
build_base() {
|
||||
# Start/Restart docker service
|
||||
start_service
|
||||
|
||||
# Prepare env in tmp
|
||||
message "Preparing env"
|
||||
make_env
|
||||
@ -39,16 +66,14 @@ build_base() {
|
||||
# import tarball to image
|
||||
message "Importing final rootfs as image"
|
||||
rootfs_to_image
|
||||
|
||||
# Push new image to docker.io
|
||||
push_image
|
||||
|
||||
# Cleanup
|
||||
message "Cleaning up"
|
||||
cleanup_env
|
||||
}
|
||||
|
||||
build_arm64() {
|
||||
# Failsafe ( decline running if not aarch64 system)
|
||||
system_type=$(uname -m)
|
||||
if [ "${system_type}" = "x86_64" ]; then
|
||||
msg_error "This is only supported for aarch64 systems"
|
||||
fi
|
||||
# Set arch specific env values
|
||||
export ARCH=arm64
|
||||
message "Building image for ${ARCH}"
|
||||
@ -57,6 +82,12 @@ build_arm64() {
|
||||
}
|
||||
|
||||
build_amd64() {
|
||||
# Failsafe ( decline running if not x86_64 system)
|
||||
system_type=$(uname -m)
|
||||
if [ "${system_type}" = "aarch64" ]; then
|
||||
msg_error "This is only supported for X86_64 systems"
|
||||
fi
|
||||
|
||||
# Set arch specific env values
|
||||
export ARCH=amd64
|
||||
|
||||
|
@ -24,7 +24,7 @@ loaded() {
|
||||
echo -e "${BLUE}[ LOADED ]: ${LBLUE}$@${WHITE}"
|
||||
|
||||
# As this function prints module loading then also lets sleep a bit so everything catches up in reality
|
||||
sleep 1
|
||||
sleep 0.3
|
||||
}
|
||||
|
||||
message() {
|
||||
|
@ -1,7 +1,15 @@
|
||||
setup_tmp() {
|
||||
mkdir -p $TMP
|
||||
if [ "${TEMP_MANAGER}" = on ]; then
|
||||
msg_debug "Not using built in tmp manager"
|
||||
else
|
||||
sudo mkdir -p $TMP
|
||||
fi
|
||||
}
|
||||
|
||||
clean_tmp() {
|
||||
rm -rf $TMP
|
||||
if [ "${TEMP_MANAGER}" = on ]; then
|
||||
msg_debug "Not using built in tmp manager"
|
||||
else
|
||||
sudo rm -rf $TMP
|
||||
fi
|
||||
}
|
||||
|
21
modules/variables.sh
Normal file
21
modules/variables.sh
Normal file
@ -0,0 +1,21 @@
|
||||
##
|
||||
# Export some needed things for head script to work with
|
||||
##
|
||||
|
||||
if [ "${TOOL_TEMP}" = "${TOOL_OUT}/tmp" ]; then
|
||||
# Export variables that are needed for usage of TOOL
|
||||
export SHOW_DEBUG=false
|
||||
export ROOT=$P_ROOT
|
||||
export TMP=$ROOT/out/tmp
|
||||
|
||||
# Dont use built in tmp manager here
|
||||
export TEMP_MANAGER=off
|
||||
else
|
||||
# Export variables that are needed with usage of independent tool
|
||||
export SHOW_DEBUG=false
|
||||
export ROOT=$(pwd)
|
||||
export TMP=$ROOT/tmp
|
||||
|
||||
# Use built in tmp manager
|
||||
export TEMP_MANAGER=on
|
||||
fi
|
Loading…
Reference in New Issue
Block a user