Skip to content

Commit

Permalink
feat: add airflow, docker run shell (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
serdigital64 authored Jan 9, 2025
1 parent bd6e8f1 commit bcdbece
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
63 changes: 63 additions & 0 deletions src/airflow/airflow-lab-run
Original file line number Diff line number Diff line change
@@ -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"
45 changes: 45 additions & 0 deletions src/core/airflow-lib
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 11 additions & 7 deletions src/docker/docker-container-run-shell
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/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.1.0
# Version: 1.0.0
#
#######################################
# Copyright [2024] [serdigital64@gmail.com]
Expand All @@ -26,9 +28,9 @@
#

declare S64_CORE_PATH_ROOT="${S64_CORE_PATH_ROOT:-/opt/sysop64}"
# shellcheck disable=SC2015 source-path=SCRIPTDIR/..
# 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,SC2154 source-path=SCRIPTDIR/../../lib/bl64
# shellcheck disable=SC2015 source-path=SCRIPTDIR/../../lib/bl64
source "${S64_CORE_PATH_BL64}/bashlib64-core.bash" || { echo 'Error: unable to load bashlib64' && exit 1; }

#
Expand All @@ -45,8 +47,9 @@ function initialize() {
# Main
#

declare M_IMAGE_NAME="${1:-alpine:latest}"
declare M_ENTRYPOINT="${2:-sh}"
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"
Expand All @@ -55,6 +58,7 @@ bl64_cnt_run_docker \
--rm \
--tty \
--interactive \
--entrypoint="$M_ENTRYPOINT" \
"$M_IMAGE_NAME"
--entrypoint="$ENTRY_POINT" \
"$CONTAINER_IMAGE" \
"$@"
bl64_msg_show_batch_finish $? "$BL64_SCRIPT_ID"

0 comments on commit bcdbece

Please sign in to comment.