Skip to content

Commit

Permalink
chore: add container dellnoantechnp/git-yq
Browse files Browse the repository at this point in the history
  • Loading branch information
dellnoantechnp committed Apr 9, 2024
1 parent f9199f9 commit e8bb737
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 0 deletions.
4 changes: 4 additions & 0 deletions initial.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

docker buildx create --name dellnoantechnp_builder --driver docker-container
docker buildx use dellnoantechnp_builder
21 changes: 21 additions & 0 deletions src/git-yq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=$TARGETPLATFORM bitnami/git:2.44.0-debian-12-r0
LABEL org.opencontainers.image.source=https://github.com/dellnoantechnp/containers \
org.opencontainers.image.description="Devops tools container images." \
org.opencontainers.image.created="2024-04-09T01:20:00Z" \
org.opencontainers.image.title="git-yq" \
org.opencontainers.image.version="2.44.0"


WORKDIR /
ENV OS_ARCH="${TARGETARCH:-amd64}" \
OS_FLAVOUR="debian-12" \
OS_NAME="${TARGETOS:-linux}"

COPY prebuildfs /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install required system packages and dependencies
RUN install_packages file procps curl netcat-openbsd ca-certificates
RUN install_packages jq wget
RUN wget https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_linux_${OS_ARCH} -O /usr/bin/yq &&\
chmod +x /usr/bin/yq
9 changes: 9 additions & 0 deletions src/git-yq/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

COMMON_PARAMETERS="--platform linux/amd64,linux/arm64 --push --progress plain"

docker buildx build -t dellnoantechnp/git-yq:2.44 ${COMMON_PARAMETERS} .

docker buildx build -t dellnoantechnp/git-yq:git_2.44_yq_4.43_jq_1.6 ${COMMON_PARAMETERS} .

docker buildx build -t dellnoantechnp/git-yq:latest ${COMMON_PARAMETERS} .
17 changes: 17 additions & 0 deletions src/git-yq/prebuildfs/opt/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# shellcheck disable=SC1091

set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purposes

# Load libraries
. /opt/scripts/liblog.sh
. /opt/scripts/libbitnami.sh

print_welcome_page

echo ""
exec "$@"
51 changes: 51 additions & 0 deletions src/git-yq/prebuildfs/opt/scripts/libbitnami.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
#
# Canal-Server custom library

# shellcheck disable=SC1091

# Load Generic Libraries
. /opt/scripts/liblog.sh

# Constants
BOLD='\033[1m'

# Functions

########################
# Print the welcome page
# Globals:
# DISABLE_WELCOME_MESSAGE
# APP_NAME
# Arguments:
# None
# Returns:
# None
#########################
print_welcome_page() {
if [[ -z "${DISABLE_WELCOME_MESSAGE:-}" ]]; then
if [[ -n "$APP_NAME" ]]; then
print_image_welcome_page
fi
fi
}

########################
# Print the welcome page for a Canal-Server Docker image
# Globals:
# APP_NAME
# Arguments:
# None
# Returns:
# None
#########################
print_image_welcome_page() {
local github_url="https://github.com/dellnoantechnp/containers"

log ""
log "${BOLD}Welcome to the ${APP_NAME} container${RESET}"
log "Subscribe to project updates by watching ${BOLD}${github_url}${RESET}"
log "Submit issues and feature requests at ${BOLD}${github_url}/issues${RESET}"
log ""
}

112 changes: 112 additions & 0 deletions src/git-yq/prebuildfs/opt/scripts/liblog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash
#
# Library for logging functions

# Constants
RESET='\033[0m'
RED='\033[38;5;1m'
GREEN='\033[38;5;2m'
YELLOW='\033[38;5;3m'
MAGENTA='\033[38;5;5m'
CYAN='\033[38;5;6m'

# Functions

########################
# Print to STDERR
# Arguments:
# Message to print
# Returns:
# None
#########################
stderr_print() {
# 'is_boolean_yes' is defined in libvalidations.sh, but depends on this file so we cannot source it
local bool="${BITNAMI_QUIET:-false}"
# comparison is performed without regard to the case of alphabetic characters
shopt -s nocasematch
if ! [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
printf "%b\\n" "${*}" >&2
fi
}

########################
# Log message
# Arguments:
# Message to log
# Returns:
# None
#########################
log() {
stderr_print "${CYAN}${MODULE:-} ${MAGENTA}$(date "+%T.%2N ")${RESET}${*}"
}
########################
# Log an 'info' message
# Arguments:
# Message to log
# Returns:
# None
#########################
info() {
log "${GREEN}INFO ${RESET} ==> ${*}"
}
########################
# Log message
# Arguments:
# Message to log
# Returns:
# None
#########################
warn() {
log "${YELLOW}WARN ${RESET} ==> ${*}"
}
########################
# Log an 'error' message
# Arguments:
# Message to log
# Returns:
# None
#########################
error() {
log "${RED}ERROR${RESET} ==> ${*}"
}
########################
# Log a 'debug' message
# Globals:
# BITNAMI_DEBUG
# Arguments:
# None
# Returns:
# None
#########################
debug() {
# 'is_boolean_yes' is defined in libvalidations.sh, but depends on this file so we cannot source it
local bool="${BITNAMI_DEBUG:-false}"
# comparison is performed without regard to the case of alphabetic characters
shopt -s nocasematch
if [[ "$bool" = 1 || "$bool" =~ ^(yes|true)$ ]]; then
log "${MAGENTA}DEBUG${RESET} ==> ${*}"
fi
}

########################
# Indent a string
# Arguments:
# $1 - string
# $2 - number of indentation characters (default: 4)
# $3 - indentation character (default: " ")
# Returns:
# None
#########################
indent() {
local string="${1:-}"
local num="${2:?missing num}"
local char="${3:-" "}"
# Build the indentation unit string
local indent_unit=""
for ((i = 0; i < num; i++)); do
indent_unit="${indent_unit}${char}"
done
# shellcheck disable=SC2001
# Complex regex, see https://github.com/koalaman/shellcheck/wiki/SC2001#exceptions
echo "$string" | sed "s/^/${indent_unit}/"
}
25 changes: 25 additions & 0 deletions src/git-yq/prebuildfs/usr/sbin/install_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -eu

n=0
max=2
export DEBIAN_FRONTEND=noninteractive

until [ $n -gt $max ]; do
set +e
(
apt-get update -qq &&
apt-get install -y --no-install-recommends "$@"
)
CODE=$?
set -e
if [ $CODE -eq 0 ]; then
break
fi
if [ $n -eq $max ]; then
exit $CODE
fi
echo "apt failed, retrying"
n=$(($n + 1))
done
apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives

0 comments on commit e8bb737

Please sign in to comment.