A set of docker image build scripts using buildx bake
 
 
 
 
Go to file
David Kebler b88ea929b0 minor refactoring of bind script
* fix image name generation
   * add logging directory and direct output to files there
removed linked mount in try script as btrfs does not create volume directories (bind mount only now)
move packages and init into separate directories to keep cache separate
fix some minor bugs
2023-03-22 09:10:54 -07:00
lib minor refactoring of bind script 2023-03-22 09:10:54 -07:00
src minor refactoring of bind script 2023-03-22 09:10:54 -07:00
.gitignore minor refactoring of bind script 2023-03-22 09:10:54 -07:00
Dockerfile minor refactoring of bind script 2023-03-22 09:10:54 -07:00
build minor refactoring of bind script 2023-03-22 09:10:54 -07:00
docker-bake.hcl minor refactoring of bind script 2023-03-22 09:10:54 -07:00
install add install script to /opt/bin 2023-01-17 15:42:56 -08:00
readme.md minor refactoring of bind script 2023-03-22 09:10:54 -07:00

readme.md

UCI Docker Image Builder

Prerequistes:

see https://hacking.kebler.net/Linux/Arch/docker/

A build script plus associated library to facilitate building docker linux images using any of four distros (arch,alpine,debian,ubuntu) and either architecture (amd64/arm64)

The Dockerfile is minimal copying a directory and then calling a packages script and and init script in two RUN statements calling a set of distro specific scripts and common scripts in order to build the image

The build environment makes user of docker's "buildx bake" commands and a docker-bake.hcl file

The master branch is configured to build base images from the docker hub distro base images

The main script is "build" At the very minimum run as just ./build it will build an alpine image from the docker hub official alpine latest image with a minimal set of packages installed (e.g. git) and a custom uci shell environment.

To run the ./build script from other repos install it using the ./install install which just creates a link in /opt/bin

ln -nsf $(dirname "$(realpath "$BASH_SOURCE")")/build /opt/bin/dbuild

The repo also supports (with scripts) pushing to alternate private repositories packages (like a self hosted gitea or github)

One can make decendent images in one of two ways.

  1. Make your base images on the master branch (or a branch if you need to customize)
  2. User the installer script (./install) to link the build script into your system path. Then clone the template branch

the build script requires an init.sh file in a source directory for the scripts it will run while building a new image by default that is <source directory>/init.sh. by default that source directory is src/ relative to the current directory

Image Build Script: Creates one or more images using a target in the docker-bake.hcl file
USAGE: /opt/bin/dbuild <subcommand> <options> <build_target> <imagename, imageuser>
valid build_target: dev arm amd deploy private multi;  default: dev
### subcommands:
try (runs try a container script, see try usage)  /opt/bin/dbuild try -i
tag  (runs image_tag script)
info get image info,  info <arch, exists, id>  nothing is all info in json
--- option switches (no argument):
-o do not overwrite an existing image (default), instead move it to a temporary timestamp tag
-i rebuild only the initialization RUN by busting the cache at that point
-v show verbose information about the build
-a (auto) do not prompt to continue build,  by default will not prompt if non-interactive shell
-c after build try out the image by starting a container terminal therein, for dev target this is the default;
-x exclude distro from image name;
-n for --no_cache
-k keep the build scripts (see -w) after the build so they are incorporated into the image
-p push to repository; after build push to repository default is hub.docker.com (not need for deploy target)
--- options with argument <ARGUMENT>:
-e <path to environment file> load any or all of options below via a file
-d <LINUX_DISTRO> supported: alpine, debian, ubuntu, default: alpine; if base image set distro will be determined
-t <TAG> tag following : in output image name (i.e.  REPO/USER/NAME:TAG), default: latest
-u <USER>;  repository user prefix in output image name (i.e.  REPO/USER/NAME:TAG)
-r <REPO>;  private repo name, do not use for hub.docker.com (docker.io)
-b <BASE_IMAGE>;  used in FROM in Dockerfile, default is official distro image (e.g. alpine:latest)
-w <BUILD_DIR>;  set a custom WORKDIR in Dockerfile (in image), default is /build, see -k
--- options set ONLY by environment variable (see -e as well)
<SYSADMIN_PW> set alternate password for container sysadmin account, default is 'sysadmin'
NOTE any option with <CAPTIALIZED> above can be set in environment instead
#### examples:
/opt/bin/dbuild -a -d ubuntu -u ucommandit
build (without prompt) a local ubuntu image from scratch and label it ucommandit/ubuntu:latest