Add template components

This commit is contained in:
2024-12-20 14:53:02 -05:00
parent 731bf7881b
commit fd4d7fcf1b
4 changed files with 78 additions and 0 deletions

18
.post-commit-hook Executable file
View File

@@ -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}"

17
LICENSE.md Normal file
View File

@@ -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.

5
README.md Normal file
View File

@@ -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`

38
setup.sh Executable file
View File

@@ -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 $@