From 537d69a25fb908603a68e89a2d3a53c3ed0cd9c4 Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Thu, 21 May 2026 19:29:54 -0400 Subject: [PATCH] initial checkin --- .gitignore | 8 ++ Containerfile | 21 ++++ README.md | 31 ++++++ pom.xml | 165 ++++++++++++++++++++++++++++++ src/main/containerd/entrypoint.sh | 41 ++++++++ 5 files changed, 266 insertions(+) create mode 100644 .gitignore create mode 100644 Containerfile create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/containerd/entrypoint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b8ef7c6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# Maven +target +pom.xml.versionsBackup + +# Eclipse +.project +.settings + diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..b0c7ed6 --- /dev/null +++ b/Containerfile @@ -0,0 +1,21 @@ + +FROM ${os.image.prefix}${os.image.name}:${os.image.version}${os.image.suffix} + +ENV SKIP_ENTRYPOINT_SCRIPTS=false +ENV VERBOSE=true + +# these are effectively immutable; provided to be used by extending images +# the entrypoint will re-set these in case they are changed +ENV CONTAINERD_ENTRYPOINT_PATH="${image.containerd.directory}" +ENV CACERT_INSTALL_PATH="/usr/local/share/ca-certificates" + +# Install curl & essentials +RUN apt update && \ + apt -y install curl + +# Add our Docker container initialization scripts +ADD --chmod=755 maven/entrypoint.sh ${image.containerd.directory}/entrypoint.sh +# RUN chmod 755 ${image.containerd.directory}/entrypoint.sh + +# Execute the Docker container initialization script +ENTRYPOINT [ "${image.containerd.directory}/entrypoint.sh" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..0fedf88 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ + +# Base Image + +This project creates a container image that provides purpose agnostic functionality to all extending images. + +## Features + +### Tools + +The following tools are available. + +- `curl` + +### Extensible `ENTRYPOINT` + +This image provides an entrypoint script that executes other entrypoint scripts, before executing the `CMD` (if provided). It will execute any executable `.sh` scripts added to the path described by the `CONTAINERD_ENTRYPOINT_PATH` environment variable. It will execute them in default sort order, so the use of numerical prefixes (`00_first.sh` or `99_last.sh`) may be wise. + +### Extensible Certificate Authority + +This image detects files in the path described by the `CACERT_INSTALL_PATH` environment variable. If a file is found, it will treat it as a certificate and add it to the trusted certificates in all supported contexts. + +## Configuration + +### Environment Variables + +| Name | Default | Mutable | +| ---------------------------- | --------------- |:-------:| +| `SKIP_ENTRYPOINT_SCRIPTS` | `false` | Yes | +| `VERBOSE` | `true` | Yes | +| `CONTAINERD_ENTRYPOINT_PATH` | *not important* | No | +| `CACERT_INSTALL_PATH` | *not important* | No | diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..832f55f --- /dev/null +++ b/pom.xml @@ -0,0 +1,165 @@ + + + 4.0.0 + com.inteligr8.container + base + ${base.version}-${os.image.name}-${os.image.version} + Base Image + This is a purpose-agnostic base image + pom + + + 1.0 + + + + + debian + 12.14 + -slim + + + inteligr8/${project.artifactId} + ${project.version} + docker.inteligr8.com + + + 1.19.0 + 1.0.7 + + + /opt/inteligr8/containerd + + + + + + src/main/containerd + true + ${project.build.directory}/resources + + + + + + org.eclipse.jkube + kubernetes-maven-plugin + ${kubernetes-maven-plugin.version} + + + com.inteligr8 + regex-maven-plugin + ${regex-maven-plugin.version} + + + + + + com.inteligr8 + regex-maven-plugin + + + determine-os-image-short-name + validate + + replace-property + + + os.image.name + os.image.shortName + + + (.{3}).+ + $1 + + + + + + determine-os-image-major-version + validate + + replace-property + + + os.image.version + os.image.majorVersion + + + ([^.]+).* + $1 + + + + + + + + maven-resources-plugin + + + copy-resources + process-resources + resources + + utf-8 + utf-8 + + + + + + + org.eclipse.jkube + kubernetes-maven-plugin + + + + ${image.name}:${image.tag} + ${image.registry} + + ${project.build.directory}/resources + ${project.basedir}/Containerfile + + ${base.version}-${os.image.shortName}${os.image.majorVersion} + + + + + true + + + + + docker-build + package + build + + + + docker-push + deploy + push + + + + + + maven-deploy-plugin + + true + + + + + + + + no-docker + + jib + + + + + diff --git a/src/main/containerd/entrypoint.sh b/src/main/containerd/entrypoint.sh new file mode 100644 index 0000000..d605a8a --- /dev/null +++ b/src/main/containerd/entrypoint.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +function ifecho() { + if [[ ${VERBOSE} == "true" ]]; then + echo "$1" + fi +} + +# error on any non-zero exit code +set -e + +# setting environment variables here so they cannot be overridden +export CONTAINERD_ENTRYPOINT_PATH="${image.containerd.directory}" +export CACERT_INSTALL_PATH="/usr/local/share/ca-certificates" + +if [[ ${SKIP_ENTRYPOINT_SCRIPTS} == "true" ]]; then + ifecho "Skipping entrypoint executions ..." +else + # execute all scripts + CONTAINERD_FILES=( ${CONTAINERD_ENTRYPOINT_PATH}/*.sh ) + if (( ${#CONTAINERD_FILES[@]} > 1 )); then + for (( CONTAINERD_FILEINDEX = 0; CONTAINERD_FILEINDEX < ${#CONTAINERD_FILES[@]}; CONTAINERD_FILEINDEX++ )); do + CONTAINERD_FILE=${CONTAINERD_FILES[$CONTAINERD_FILEINDEX]} + if [[ ${CONTAINERD_FILE} != "${CONTAINERD_ENTRYPOINT_PATH}/entrypoint.sh" ]]; then + ifecho "Executing entrypoint: ${CONTAINERD_FILE}" + . ${CONTAINERD_FILE} + fi + done + fi +fi + +if ! find ${CACERT_INSTALL_PATH}/ -maxdepth 0 -empty | read JUNK; then + # update cacerts with any custom certs in /usr/local/share/ca-certificates + ifecho "Updating CA certificates ..." + update-ca-certificates +fi + +if [[ ! -z $1 ]]; then + ifecho "Executing command ..." + exec "$@" +fi