From fd4d7fcf1b4111cd7373b0fee842107ed6651070 Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Fri, 20 Dec 2024 14:53:02 -0500 Subject: [PATCH] Add template components --- .post-commit-hook | 18 ++++++++++++++++++ LICENSE.md | 17 +++++++++++++++++ README.md | 5 +++++ setup.sh | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100755 .post-commit-hook create mode 100644 LICENSE.md create mode 100644 README.md create mode 100755 setup.sh diff --git a/.post-commit-hook b/.post-commit-hook new file mode 100755 index 0000000..f56ff6c --- /dev/null +++ b/.post-commit-hook @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +BASE_IMAGE=$(git config get toolbox-dev-env.base-image.name) +if git config get toolbox-dev-env.base-image.version-script; then + BASE_IMAGE_VERSION=eval $(git config get toolbox-dev-env.base-image.version-script) +else + BASE_IMAGE_VERSION=$(git config get toolbox-dev-env.base-image.version) +fi +BUILD_NONCE=$(git rev-parse HEAD) + +ENV_NAME=$(git config get toolbox-dev-env.name) + +podman build . \ + --tag "localhost/${ENV_NAME}:latest" \ + --build-arg BASE_IMAGE="${BASE_IMAGE}" \ + --build-arg BASE_IMAGE_VERSION="${BASE_IMAGE_VERSION}" \ + --build-arg BUILD_NONCE="${BUILD_NONCE}" \ + --build-arg ENV_NAME="${ENV_NAME}" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..abd6d1a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,17 @@ +## Copyright 2024 Ethan Paul + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or +substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2b5aca7 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# toolbox dev env + +A base development environment for building [Toolbox](https://containertoolbx.org/) containers from + +For initial repo setup, be certain to run `./setup.sh`. After initial setup, use `./configure.sh` diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..ea5efc9 --- /dev/null +++ b/setup.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +function configure() { + echo "cp .post-commit-hook .git/hooks/post-commit">./configure.sh + + read -p "Enter a name for this environment [development]: " envName + local envName=${baseName:-development} + echo "git config set toolbox-dev-env.name ${envName}">>./configure.sh + + read -p "Enter path of base image [registry.fedoraproject.org/fedora-toolbox]: " baseImage + local baseImage=${baseImage:-registry.fedoraproject.org/fedora-toolbox} + echo "git config set toolbox-dev-env.base-image.name ${baseImage}">>./configure.sh + + read -p "Would you like to use a command to determine the base image version [y/N] " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + read -p "Enter command to determine base image version: " baseImageVersionCommand + echo "git config set toolbox-dev-env.base-image.version-script '${baseImageVersionCommand}'">>./configure.sh + echo "git config unset toolbox-dev-env.base-image.version">>./configure.sh + else + read -p "Enter base image version: " baseImageVersion + echo "git config set toolbox-dev-env.base-image.version ${baseImageVersion}">>./configure.sh + echo "git config unset toolbox-dev-env.base-image.version-script">>./configure.sh + fi +} + +function main() { + trap "rm -f configure.sh" 1 2 3 + + configure + chmod +x ./configure.sh + bash ./configure.sh + + echo "Setup is now completed. Please commit 'configure.sh' to persist the configuration" + rm setup.sh +} + +main $@