diff --git a/Dockerfile b/Dockerfile index 045d6a1..b388f0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,12 +24,6 @@ COPY scripts/installation/ scripts/installation/ # Install distro-specific build dependencies (including make) RUN bash scripts/installation/dependencies.sh -# ------------------------------------------------------------ -# Image cleanup (reduce final size) -# ------------------------------------------------------------ -COPY scripts/docker/slim.sh /usr/local/bin/slim.sh -RUN chmod +x /usr/local/bin/slim.sh && /usr/local/bin/slim.sh - # Virgin default CMD ["bash"] @@ -39,6 +33,7 @@ CMD ["bash"] # - inherits from virgin # - builds + installs pkgmgr # - sets entrypoint + default cmd +# - NOTE: does NOT run slim.sh (that is done in slim stage) # ============================================================ FROM virgin AS full @@ -58,10 +53,16 @@ COPY scripts/docker/entry.sh /usr/local/bin/docker-entry.sh WORKDIR /opt/src/pkgmgr ENTRYPOINT ["/usr/local/bin/docker-entry.sh"] - -# ------------------------------------------------------------ -# Image cleanup (reduce final size) -# ------------------------------------------------------------ -RUN /usr/local/bin/slim.sh - CMD ["pkgmgr", "--help"] + + +# ============================================================ +# Target: slim +# - based on full +# - runs slim.sh +# ============================================================ +FROM full AS slim + +COPY scripts/docker/slim.sh /usr/local/bin/slim.sh +RUN chmod +x /usr/local/bin/slim.sh +RUN /usr/local/bin/slim.sh diff --git a/scripts/build/image.sh b/scripts/build/image.sh index d8029d7..e868ad9 100755 --- a/scripts/build/image.sh +++ b/scripts/build/image.sh @@ -33,7 +33,7 @@ Usage: PKGMGR_DISTRO= $0 [options] Build options: --missing Build only if the image does not already exist (local build only) --no-cache Build with --no-cache - --target Build a specific Dockerfile target (e.g. virgin) + --target Build a specific Dockerfile target (e.g. virgin, slim) --tag Override the output image tag (default: ${default_tag}) Publish options: @@ -47,7 +47,7 @@ Publish options: Notes: - --publish implies --push and requires --registry, --owner, and --version. -- Local build (no --push) uses "docker build" and creates local images like "pkgmgr-arch" / "pkgmgr-arch-virgin". +- Local build (no --push) uses "docker build" and creates local images like "pkgmgr-arch" / "pkgmgr-arch-virgin" / "pkgmgr-arch-slim". EOF } @@ -57,7 +57,7 @@ while [[ $# -gt 0 ]]; do --missing) MISSING_ONLY=1; shift ;; --target) TARGET="${2:-}" - [[ -n "${TARGET}" ]] || { echo "ERROR: --target requires a value (e.g. virgin)"; exit 2; } + [[ -n "${TARGET}" ]] || { echo "ERROR: --target requires a value (e.g. virgin|slim)"; exit 2; } shift 2 ;; --tag) diff --git a/scripts/build/publish.sh b/scripts/build/publish.sh index 37a7c8a..5f20410 100755 --- a/scripts/build/publish.sh +++ b/scripts/build/publish.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -# Publish all distro images (full + virgin) to a registry via image.sh --publish +# Publish all distro images (full + virgin + slim) to a registry via image.sh --publish # # Required env: # OWNER (e.g. GITHUB_REPOSITORY_OWNER) @@ -11,6 +11,9 @@ set -euo pipefail # REGISTRY (default: ghcr.io) # IS_STABLE (default: false) # DISTROS (default: "arch debian ubuntu fedora centos") +# +# Notes: +# - This expects Dockerfile targets: virgin, full (default), slim SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" @@ -33,7 +36,10 @@ for d in ${DISTROS}; do echo "[publish] PKGMGR_DISTRO=${d}" echo "============================================================" + # ---------------------------------------------------------- # virgin + # -> ghcr.io//pkgmgr--virgin:{latest,,stable?} + # ---------------------------------------------------------- PKGMGR_DISTRO="${d}" bash "${SCRIPT_DIR}/image.sh" \ --publish \ --registry "${REGISTRY}" \ @@ -42,13 +48,29 @@ for d in ${DISTROS}; do --stable "${IS_STABLE}" \ --target virgin + # ---------------------------------------------------------- # full (default target) + # -> ghcr.io//pkgmgr-:{latest,,stable?} + # ---------------------------------------------------------- PKGMGR_DISTRO="${d}" bash "${SCRIPT_DIR}/image.sh" \ --publish \ --registry "${REGISTRY}" \ --owner "${OWNER}" \ --version "${VERSION}" \ --stable "${IS_STABLE}" + + # ---------------------------------------------------------- + # slim + # -> ghcr.io//pkgmgr--slim:{latest,,stable?} + # + alias for default distro: ghcr.io//pkgmgr-slim:{...} + # ---------------------------------------------------------- + PKGMGR_DISTRO="${d}" bash "${SCRIPT_DIR}/image.sh" \ + --publish \ + --registry "${REGISTRY}" \ + --owner "${OWNER}" \ + --version "${VERSION}" \ + --stable "${IS_STABLE}" \ + --target slim done echo