From 7d92240eed4f35048fd2d2a68863f38461343dab Mon Sep 17 00:00:00 2001 From: serdigital64 Date: Wed, 8 Jan 2025 22:03:54 +0000 Subject: [PATCH 1/5] feat: add docker run shell --- CHANGELOG.md | 7 +++ src/docker/docker-container-run-shell | 62 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 src/docker/docker-container-run-shell diff --git a/CHANGELOG.md b/CHANGELOG.md index c61ea87..6caed11 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.18.0] + +### Added + +- Docker + - docker-container-run-shell + ## [0.17.0] ### Added diff --git a/src/docker/docker-container-run-shell b/src/docker/docker-container-run-shell new file mode 100755 index 0000000..c625ed2 --- /dev/null +++ b/src/docker/docker-container-run-shell @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# template-one: 2.0.0 +# template-one-base: 1.0.0 +# template-import: 2.0.0 +####################################### +# Docker / Container / Run / Shell +# +# Version: 1.0.0 +# +####################################### +# Copyright [2024] [serdigital64@gmail.com] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################### + +# +# Imports +# + +declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" +# shellcheck source-path=SCRIPTDIR/.. +source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/docker-lib" || { echo "Error: unable to load module library" && exit 1; } +# shellcheck disable=SC2015 source-path=SCRIPTDIR/../../lib/bl64 +source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } + +# +# Functions +# + +function initialize() { + bl64_dbg_app_show_function + s64_docker_lib_setup && + bl64_cnt_check_not_in_container +} + +# +# Main +# + +declare CONTAINER_IMAGE="${1:-alpine:latest}" +declare ENTRY_POINT="${2:-sh}" + +bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? +bl64_msg_show_batch_start "$BL64_SCRIPT_ID" +bl64_cnt_run_docker \ + run \ + --rm \ + --tty \ + --interactive \ + --entrypoint="$ENTRY_POINT" \ + "$CONTAINER_IMAGE" +bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" From 652d0f52fa61ee791e5ef84a8987c911679797f1 Mon Sep 17 00:00:00 2001 From: serdigital64 Date: Wed, 8 Jan 2025 22:03:58 +0000 Subject: [PATCH 2/5] fix: missing param --- src/docker/docker-image-cleanup | 4 ++-- src/docker/docker-system-prune | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/docker/docker-image-cleanup b/src/docker/docker-image-cleanup index 3c57dbb..4cc3b3c 100755 --- a/src/docker/docker-image-cleanup +++ b/src/docker/docker-image-cleanup @@ -3,7 +3,7 @@ ####################################### # Docker / Image / Cleanup # -# Version: 1.1.0 +# Version: 1.1.1 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -27,7 +27,7 @@ declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" # shellcheck disable=SC2015 source-path=SCRIPTDIR/.. -source "${S64_CORE_PATH_ROOT}/core/core-lib" source "${S64_CORE_PATH_ROOT}/core/docker-lib" || { echo "Error: unable to load module library" && exit 1; } +source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/docker-lib" || { echo "Error: unable to load module library" && exit 1; } # shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } diff --git a/src/docker/docker-system-prune b/src/docker/docker-system-prune index 52530f0..0948d0e 100755 --- a/src/docker/docker-system-prune +++ b/src/docker/docker-system-prune @@ -3,7 +3,7 @@ ####################################### # Docker / System / Prune # -# Version: 1.1.0 +# Version: 1.1.1 # ####################################### # Copyright [2024] [serdigital64@gmail.com] @@ -27,7 +27,7 @@ declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" # shellcheck disable=SC2015 source-path=SCRIPTDIR/.. -source "${S64_CORE_PATH_ROOT}/core/core-lib" source "${S64_CORE_PATH_ROOT}/core/docker-lib" || { echo "Error: unable to load module library" && exit 1; } +source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/docker-lib" || { echo "Error: unable to load module library" && exit 1; } # shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } From 987da84d64919e214a2b76b813199dc6138d5ed3 Mon Sep 17 00:00:00 2001 From: serdigital64 Date: Wed, 8 Jan 2025 23:38:10 +0000 Subject: [PATCH 3/5] dev: upgrade db64 --- .devbin64 | 2 +- bin/dev-git-repo-pull | 81 +++++++++++++++++++++++++++++++++++++++++++ bin/dev-set | 7 ++-- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100755 bin/dev-git-repo-pull diff --git a/.devbin64 b/.devbin64 index dfda3e0..dc0208a 100644 --- a/.devbin64 +++ b/.devbin64 @@ -1 +1 @@ -6.1.0 +6.3.1 diff --git a/bin/dev-git-repo-pull b/bin/dev-git-repo-pull new file mode 100755 index 0000000..cc91840 --- /dev/null +++ b/bin/dev-git-repo-pull @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +####################################### +# Dev / GIT / Get latest changes from upstram and origin +# +# * Version: 1.0.0 +# +####################################### +# Copyright [2023] [serdigital64@gmail.com] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################### + +# +# Imports +# + +# shellcheck source=bin/dev-set +source ./bin/dev-set || { echo 'dev-set:Error: unable to load dev environment' 2>&1 && exit 1; } +# shellcheck source-path=bin +source ./bin/dev-env-git || exit 1 +# shellcheck source-path=lib/bl64 +source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-xsv.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-bsh.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-fmt.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-fs.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-rxtx.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-txt.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-api.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-module-vcs.bash" && + source "${DEV_LIB_BASHLIB64_TARGET}/bashlib64-core.bash" || exit 1 + +# +# Functions +# + +function dev_repo_pull() { + bl64_dbg_app_show_function + + bl64_msg_show_task "switch to main branch (${DEV_GIT_BRANCH_MAIN})" + bl64_vcs_run_git checkout "$DEV_GIT_BRANCH_MAIN" || + return $? + + if bl64_lib_flag_is_enabled "$DEV_GIT_REMOTE_UPSTREAM_ENABLED"; then + bl64_msg_show_task "pull latest changes from upstream (${DEV_GIT_REMOTE_UPSTREAM})" + bl64_vcs_run_git fetch "$DEV_GIT_REMOTE_UPSTREAM" && + bl64_vcs_run_git pull "$DEV_GIT_REMOTE_UPSTREAM" "$DEV_GIT_BRANCH_MAIN" + else + bl64_msg_show_task "pull latest changes from origin (${DEV_GIT_REMOTE_ORIGIN})" + bl64_vcs_run_git fetch "$DEV_GIT_REMOTE_ORIGIN" && + bl64_vcs_run_git pull "$DEV_GIT_REMOTE_ORIGIN" "$DEV_GIT_BRANCH_MAIN" + fi + bl64_msg_show_task 'run local garbage collector' + bl64_vcs_run_git gc +} + +function dev_git_initialize() { + bl64_dbg_app_show_function + bl64_vcs_setup +} + +# +# Main +# + +[[ -n "$DEV_CICD_DEBUG" ]] && bl64_dbg_all_enable + +bl64_msg_all_enable_verbose +bl64_msg_show_batch_start 'dev-git-repo-pull' +dev_git_initialize && + dev_repo_pull +bl64_msg_show_batch_finish $? 'dev-git-repo-pull' diff --git a/bin/dev-set b/bin/dev-set index 9b4ef0b..8e7ec53 100755 --- a/bin/dev-set +++ b/bin/dev-set @@ -5,7 +5,7 @@ # * Loads DevBin64 environment variables # * To be used by DevBin64 scripts # * Warning: Bash is the only supported shell. Other shells may work as long as they are compatible with Bash syntax -# * Version: 8.2.1 +# * Version: 8.3.1 # ####################################### # Copyright [2023] [serdigital64@gmail.com] @@ -29,6 +29,7 @@ # Main / Debug flag for bin/ scripts export DEV_CICD_DEBUG="${DEV_CICD_DEBUG:-}" +[[ -n "$DEV_CICD_DEBUG" ]] && set -x # Main / Increase verbosity? Set to YES to increase export DEV_SET_VERBOSE="${DEV_SET_VERBOSE:-}" # Main / Bootstrap files. Must be the same as defined in .env @@ -39,6 +40,8 @@ export DEV_BASE_ENV='.env' export DEV_PATH_ROOT="${DEV_PATH_ROOT:-}" # Main / List of modules to load export DEV_MODULE_LOAD="${DEV_MODULE_LOAD:-}" +# Main / Profile +export DEV_PROFILE="${DEV_PROFILE:-}" # From CICD products export GITHUB_WORKSPACE="${GITHUB_WORKSPACE:-}" @@ -178,8 +181,6 @@ function dev_set_initialize() { # Main # -[[ -n "$DEV_CICD_DEBUG" ]] && set -x - # shellcheck disable=SC2015 dev_set_initialize && dev_set_load_local && From e7b157703e68e401384c59fb5c52897a1bea7f99 Mon Sep 17 00:00:00 2001 From: serdigital64 Date: Wed, 8 Jan 2025 23:38:30 +0000 Subject: [PATCH 4/5] feat: add extra args --- src/docker/docker-container-run-shell | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docker/docker-container-run-shell b/src/docker/docker-container-run-shell index c625ed2..62ddf5d 100755 --- a/src/docker/docker-container-run-shell +++ b/src/docker/docker-container-run-shell @@ -49,6 +49,7 @@ function initialize() { declare CONTAINER_IMAGE="${1:-alpine:latest}" declare ENTRY_POINT="${2:-sh}" +shift; shift bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? bl64_msg_show_batch_start "$BL64_SCRIPT_ID" @@ -58,5 +59,6 @@ bl64_cnt_run_docker \ --tty \ --interactive \ --entrypoint="$ENTRY_POINT" \ - "$CONTAINER_IMAGE" + "$CONTAINER_IMAGE" \ + "$@" bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" From ff709f0b2abbe33234e6a99f951651ce994e41c1 Mon Sep 17 00:00:00 2001 From: serdigital64 Date: Wed, 8 Jan 2025 23:54:27 +0000 Subject: [PATCH 5/5] feat: add airflow --- CHANGELOG.md | 2 ++ src/airflow/airflow-lab-run | 63 +++++++++++++++++++++++++++++++++++++ src/core/airflow-lib | 45 ++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100755 src/airflow/airflow-lab-run create mode 100755 src/core/airflow-lib diff --git a/CHANGELOG.md b/CHANGELOG.md index 6caed11..4551538 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Module + - AirFlow - Docker - docker-container-run-shell diff --git a/src/airflow/airflow-lab-run b/src/airflow/airflow-lab-run new file mode 100755 index 0000000..030b637 --- /dev/null +++ b/src/airflow/airflow-lab-run @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# template-one: 2.0.0 +####################################### +# Airflow / Lab / Run +# +# Version: 1.0.0 +# +####################################### +# Copyright [2024] [serdigital64@gmail.com] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################### + +# +# Imports +# + +declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}" +# shellcheck source-path=SCRIPTDIR/.. +source "${S64_CORE_PATH_ROOT}/core/core-lib" && source "${S64_CORE_PATH_ROOT}/core/airflow-lib" || { echo "Error: unable to load module library" && exit 1; } +# shellcheck disable=SC2015 source-path=SCRIPTDIR/../../lib/bl64 +source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; } + +# +# Functions +# + +function initialize() { + bl64_dbg_app_show_function + s64_airflow_lib_setup +} + +# +# Main +# + +declare MAIN_HOST_PORT="${1:-8080}" +declare MAIN_CONTAINER_VERSION="${2:-latest}" + +bl64_dbg_set_level "$S64_CORE_SET_DEBUG" && bl64_msg_set_level "$S64_CORE_SET_VERBOSE" && initialize || exit $? +bl64_msg_show_setup 'Run AirFlow Standalone container for local lab testing' \ + 'MAIN_HOST_PORT' \ + 'MAIN_CONTAINER_VERSION' +bl64_msg_show_batch_start "$BL64_SCRIPT_ID" +bl64_cnt_run_docker \ + run \ + --rm \ + --tty \ + --interactive \ + --publish 8080:8080 \ + apache/airflow:latest \ + standalone +bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID" diff --git a/src/core/airflow-lib b/src/core/airflow-lib new file mode 100755 index 0000000..0af15d9 --- /dev/null +++ b/src/core/airflow-lib @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# template-module-lib: 2.0.0 +####################################### +# Airflow / Lib +# +# Version: 1.0.0 +# +####################################### +# Copyright [2024] [serdigital64@gmail.com] +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################### + +# +# Imports +# + +# shellcheck disable=SC2015,SC2154 source-path=SCRIPTDIR/../../lib/bl64 +source "${S64_CORE_PATH_BL64}/bashlib64-module-fs.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-txt.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-xsv.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-fmt.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-bsh.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-cnt.bash" && + source "${S64_CORE_PATH_BL64}/bashlib64-module-bsh.bash" || + { echo 'Error: unable to load bashlib64' && exit 1; } + +# +# Functions +# + +function s64_airflow_lib_setup() { + bl64_dbg_app_show_function + bl64_cnt_setup +}