Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[![Visit Images on DockerHub](https://img.shields.io/badge/DockerHub-Images-green)](https://hub.docker.com/u/LabNow)

Please generously STAR★ our project or donate to us! [![GitHub Starts](https://img.shields.io/github/stars/LabNow-ai/lab-foundation.svg?label=Stars)](https://github.com/LabNow-ai/lab-foundation/stargazers)
[![Donate-PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/haobibo)
[![Donate-AliPay](https://img.shields.io/badge/Donate-Alipay-blue.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-AliPay.png)
[![Donate-WeChat](https://img.shields.io/badge/Donate-WeChat-green.svg)](https://raw.githubusercontent.com/wiki/haobibo/resources/img/Donate-WeChat.png)

Discussion and contributions are welcome:
[![Join the Discord Chat](https://img.shields.io/badge/Discuss_on-Discord-green)](https://discord.gg/kHUzgQxgbJ)
Expand Down
155 changes: 106 additions & 49 deletions docker_atom/work/script-setup-core.sh

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions docker_atom/work/script-setup-db-clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ setup_postgresql_client() {
echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
# will download ~9MB files and use ~55MB disk after installation
sudo apt-get update && sudo apt-get -y install "postgresql-client-${VER_PG}"

type psql && echo "@ Version of psql client: $(psql --version)" || return -1
}

setup_duckdb() {
local ARCH="$(uname -m)" \
&& local ARCH_DUCKDB=$([ "$ARCH" = "x86_64" ] && echo "amd64" || echo "arm64") \
&& local VER_DUCKDB="${1:-$(curl -s https://api.github.com/repos/duckdb/duckdb/releases/latest | grep -oP '"tag_name":\s*"\K[^"]+' | sed 's/^v//')}" \
&& local VER_DUCKDB_REQ="${1:-}" \
&& local VERS_DUCKDB=$(curl -s https://api.github.com/repos/duckdb/duckdb/releases | grep -oP '"tag_name":\s*"\K[^"]+' | sed 's/^v//' | sort -rV) \
&& if [ -n "${VER_DUCKDB_REQ}" ]; then
local VER_DUCKDB_RE=${VER_DUCKDB_REQ#v} \
&& VER_DUCKDB_RE=${VER_DUCKDB_RE//./\\.} \
&& local VER_DUCKDB=$(echo "${VERS_DUCKDB}" | grep -m1 -E "^${VER_DUCKDB_RE}([.-]|$)")
else
local VER_DUCKDB=$(echo "${VERS_DUCKDB}" | head -1)
fi \
&& [ -n "${VER_DUCKDB}" ] \
&& local URL_DUCKDB="https://github.com/duckdb/duckdb/releases/download/v${VER_DUCKDB}/duckdb_cli-linux-${ARCH_DUCKDB}.zip" \
&& local TMP_FILE="/tmp/duckdb-${VER_DUCKDB}.zip" \
&& echo "Downloading DuckDB ${VER_DUCKDB} from: ${URL_DUCKDB}" \
Expand All @@ -24,7 +32,6 @@ setup_duckdb() {
&& mkdir -pv /opt/bin \
&& install -m 0755 /tmp/duckdb /opt/bin/duckdb \
&& rm -f "${TMP_FILE}" /tmp/duckdb ;

/opt/bin/duckdb --version && echo "@ DuckDB installed" || return -1 ;
}

Expand Down
40 changes: 32 additions & 8 deletions docker_atom/work/script-setup-net.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,62 @@
setup_traefik() {
VER_TRAEFIK="${1:-$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+')}" \
local VER_TRAEFIK_REQ="${1:-}" \
&& local VERS_TRAEFIK=$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | grep -Po '\d[\d.]+' | sort -rV) \
&& if [ -n "${VER_TRAEFIK_REQ}" ]; then
local VER_TRAEFIK_RE=${VER_TRAEFIK_REQ#v} \
&& VER_TRAEFIK_RE=${VER_TRAEFIK_RE//./\\.} \
&& local VER_TRAEFIK=$(echo "${VERS_TRAEFIK}" | grep -m1 -E "^${VER_TRAEFIK_RE}([.-]|$)")
else
local VER_TRAEFIK=$(echo "${VERS_TRAEFIK}" | head -1)
fi \
&& [ -n "${VER_TRAEFIK}" ] \
&& URL_TRAEFIK="https://github.com/traefik/traefik/releases/download/v${VER_TRAEFIK}/traefik_v${VER_TRAEFIK}_linux_$(dpkg --print-architecture).tar.gz" \
&& curl -o /tmp/TMP.tgz -sL "${URL_TRAEFIK}" \
&& mkdir -pv /opt/bin && tar -C /opt/bin -xzf /tmp/TMP.tgz traefik && rm /tmp/TMP.tgz \
&& chmod +x /opt/bin/traefik && ln -sf /opt/bin/traefik /usr/bin/ ;

type traefik && echo "@ Version of traefik: $(traefik version)" || return -1 ;
}

setup_caddy() {
UNAME=$(uname | tr '[:upper:]' '[:lower:]') \
&& ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') \
&& VER_CADDY="${1:-$(curl -sL https://github.com/caddyserver/caddy/releases.atom | grep "releases/tag" | grep -v 'beta' | head -1 | grep -Po '(\d[\d|.]+)')}" \
&& local VER_CADDY_REQ="${1:-}" \
&& local VERS_CADDY=$(curl -sL https://github.com/caddyserver/caddy/releases.atom | grep "releases/tag" | grep -v 'beta' | grep -Po '(\d[\d|.]+)' | sort -rV) \
&& if [ -n "${VER_CADDY_REQ}" ]; then
local VER_CADDY_RE=${VER_CADDY_REQ#v} \
&& VER_CADDY_RE=${VER_CADDY_RE//./\\.} \
&& local VER_CADDY=$(echo "${VERS_CADDY}" | grep -m1 -E "^${VER_CADDY_RE}([.-]|$)")
else
local VER_CADDY=$(echo "${VERS_CADDY}" | head -1)
fi \
&& [ -n "${VER_CADDY}" ] \
&& URL_CADDY="https://github.com/caddyserver/caddy/releases/download/v${VER_CADDY}/caddy_${VER_CADDY}_${UNAME}_${ARCH}.tar.gz" \
&& echo "Downloading Caddy ${VER_CADDY} from ${URL_CADDY}" \
&& curl -o /tmp/TMP.tgz -sL "${URL_CADDY}" && tar -C /tmp/ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \
&& mkdir -pv /opt/bin/ && mv /tmp/caddy /opt/bin/ && ln -sf /opt/bin/caddy /usr/local/bin/ ;

type caddy && echo "@ Version of caddy: $(caddy version)" || return -1 ;
}

setup_oauth2_proxy() {
local ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/' -e 's/armv7l/armv7/') ;
[[ "$ARCH" =~ ^(amd64|arm64|armv7)$ ]] || { echo "Unsupported architecture for oauth2-proxy: $(uname -m)"; return 1; }

local VER_OAUTH2_PROXY="${1:-$(curl -sL -o /dev/null -w "%{url_effective}" https://github.com/oauth2-proxy/oauth2-proxy/releases/latest | grep -oP 'v\K[\d.]+')}" \
local VER_OAUTH2_PROXY_REQ="${1:-}" \
&& local VERS_OAUTH2_PROXY=$(curl -sL https://github.com/oauth2-proxy/oauth2-proxy/releases.atom | grep 'releases/tag' | grep -Po '(?<=tag/v)\d[\d.]+' | sort -rV) \
&& if [ -n "${VER_OAUTH2_PROXY_REQ}" ]; then
local VER_OAUTH2_PROXY_RE=${VER_OAUTH2_PROXY_REQ#v} \
&& VER_OAUTH2_PROXY_RE=${VER_OAUTH2_PROXY_RE//./\\.} \
&& local VER_OAUTH2_PROXY=$(echo "${VERS_OAUTH2_PROXY}" | grep -m1 -E "^${VER_OAUTH2_PROXY_RE}([.-]|$)")
else
local VER_OAUTH2_PROXY=$(echo "${VERS_OAUTH2_PROXY}" | head -1)
fi \
&& [ -n "${VER_OAUTH2_PROXY}" ] \
&& local FILE_OAUTH2_PROXY="oauth2-proxy-v${VER_OAUTH2_PROXY}.linux-${ARCH}.tar.gz" \
&& local URL_OAUTH2_PROXY="https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v${VER_OAUTH2_PROXY}/${FILE_OAUTH2_PROXY}" \
&& echo "Installing oauth2-proxy v${VER_OAUTH2_PROXY} for arch ${ARCH} from: ${URL_OAUTH2_PROXY}" \
&& curl -fSL "${URL_OAUTH2_PROXY}" -o /tmp/oauth2-proxy.tar.gz \
&& tar -xzf /tmp/oauth2-proxy.tar.gz -C /tmp \
&& install -m 0755 -D "/tmp/oauth2-proxy-v${VER_OAUTH2_PROXY}.linux-${ARCH}/oauth2-proxy" /opt/bin/oauth2-proxy \
&& ln -sf /opt/bin/oauth2-proxy /usr/bin/oauth2-proxy \
&& rm -rf /tmp/oauth2-proxy*

type oauth2-proxy && echo "@ Installed oauth2-proxy: $(oauth2-proxy --version)"
&& rm -rf /tmp/oauth2-proxy* ;
type oauth2-proxy && echo "@ Installed oauth2-proxy: $(oauth2-proxy --version)" ;
}
24 changes: 20 additions & 4 deletions docker_atom/work/script-setup-sys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ source /opt/utils/script-utils.sh

setup_tini() {
ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') \
&& VER_TINI="${1:-$(curl -sL https://github.com/krallin/tini/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' )}" \
&& local VER_TINI_REQ="${1:-}" \
&& local VERS_TINI=$(curl -sL https://github.com/krallin/tini/releases.atom | grep 'releases/tag' | grep -Po '\d[\d.]+' | sort -rV) \
&& if [ -n "${VER_TINI_REQ}" ]; then
local VER_TINI_RE=${VER_TINI_REQ#v} \
&& VER_TINI_RE=${VER_TINI_RE//./\\.} \
&& local VER_TINI=$(echo "${VERS_TINI}" | grep -m1 -E "^${VER_TINI_RE}([.-]|$)")
else
local VER_TINI=$(echo "${VERS_TINI}" | head -1)
fi \
&& [ -n "${VER_TINI}" ] \
&& URL_TINI="https://github.com/krallin/tini/releases/download/v${VER_TINI}/tini-${ARCH}" \
&& echo "Downloading Tini ${VER_TINI} from ${URL_TINI}" \
&& curl -o /usr/bin/tini -sL $URL_TINI && chmod +x /usr/bin/tini ;

type tini && echo "@ Version of tini: $(tini --version)" || return -1 ;
# ref: https://cloud-atlas.readthedocs.io/zh-cn/latest/docker/init/docker_tini.html
# to run multi-proces with tini: use a bash script ends with the following code
Expand All @@ -18,12 +26,20 @@ setup_tini() {
setup_supervisord() {
UNAME=$(uname | tr '[:upper:]' '[:lower:]') \
&& ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') \
&& VER_SUPERVISORD="${1:-$(curl -sL https://github.com/LabNow-ai/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)')}" \
&& local VER_SUPERVISORD_REQ="${1:-}" \
&& local VERS_SUPERVISORD=$(curl -sL https://github.com/LabNow-ai/supervisord/releases.atom | grep "releases/tag" | grep -Po '(\d[\d|.]+)' | sort -rV) \
&& if [ -n "${VER_SUPERVISORD_REQ}" ]; then
local VER_SUPERVISORD_RE=${VER_SUPERVISORD_REQ#v} \
&& VER_SUPERVISORD_RE=${VER_SUPERVISORD_RE//./\\.} \
&& local VER_SUPERVISORD=$(echo "${VERS_SUPERVISORD}" | grep -m1 -E "^${VER_SUPERVISORD_RE}([.-]|$)")
else
local VER_SUPERVISORD=$(echo "${VERS_SUPERVISORD}" | head -1)
fi \
&& [ -n "${VER_SUPERVISORD}" ] \
&& URL_SUPERVISORD="https://github.com/LabNow-ai/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${UNAME}_${ARCH}.tar.gz" \
&& echo "Downloading Supervisord ${VER_SUPERVISORD} from ${URL_SUPERVISORD}" \
&& curl -o /tmp/TMP.tgz -sL $URL_SUPERVISORD && tar -C /tmp/ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \
&& mkdir -pv /opt/bin/ && mv /tmp/supervisord /opt/bin/ && ln -sf /opt/bin/supervisord /usr/local/bin/ ;

type supervisord && echo "@ Version of supervisord: $(supervisord version)" || return -1 ;
}

Expand Down
35 changes: 18 additions & 17 deletions docker_core/core.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ COPY work /opt/utils/

RUN set -eux \
&& source /opt/utils/script-setup-core.sh \
# -----------------------------
## -----------------------------
&& echo "NodeJS is required to build some components like JupyterLab Extensions later" \
&& for profile in $(echo $ARG_PROFILE_NODEJS | tr "," "\n") ; do ( setup_node_${profile} ) ; done \
# -----------------------------
## -----------------------------
&& echo "If installing Java environment - notice that Java can be dependency for some other packages like rJava" \
&& export VERSION_JDK=${VERSION_JDK:-11} \
&& for profile in $(echo $ARG_PROFILE_JAVA | tr "," "\n") ; do ( setup_java_${profile} ) ; done \
# -----------------------------
## -----------------------------
&& echo "If installing LaTex and LaTex CJK packages." \
&& for profile in $(echo $ARG_PROFILE_LATEX | tr "," "\n") ; do ( install_apt "/opt/utils/install_list_latex_${profile}.apt" ) ; done \
# -----------------------------
## -----------------------------
&& echo "If installing R environment - put this after Java ready to configure rJava" \
&& source /opt/utils/script-setup-R.sh \
&& for profile in $(echo $ARG_PROFILE_R | tr "," "\n") ; do ( setup_R_${profile} ) ; done \
&& ( which R && ln -sf "${CONDA_PREFIX}"/bin/python3.* /usr/bin/ || true ) && ls -alh /usr/bin/python* \
# -----------------------------
## -----------------------------
&& echo "If on a x86_64 architecture: 1) if mkl specified, install nomkl; 2) install conda packages as specified." \
&& if echo $(arch) | grep -q "x86_64" ; then \
echo "mkl" >> /opt/utils/install_list_core.conda && echo "Install mkl." ; \
Expand All @@ -54,38 +54,39 @@ RUN set -eux \
fi \
&& ln -sf /opt/utils/install_list_core.conda /opt/utils/install_list_PY_mkl.pip \
&& install_mamba /opt/utils/install_list_core.conda \
# -----------------------------
## -----------------------------
&& echo "If installing Python packages" \
&& ( $(grep -q "datascience" <<< "${ARG_PROFILE_PYTHON}") && ( \
( which R && echo "rpy2 % Install rpy2 if R exists" >> /opt/utils/install_list_PY_datascience.pip || echo "Skip rpy2 install" ) \
&& ( which java && echo "py4j % Install py4j if Java exists" >> /opt/utils/install_list_PY_datascience.pip || echo "Skip py4j install" ) \
) || echo "Skip Python datascience packages install" ) \
# -----------------------------
&& export CUDA_VER=$(echo ${CUDA_VERSION:-"999"} | cut -c1-4 | sed 's/\.//' ) \
## -----------------------------
&& export DEFAULT_CUDA_VERSION_FALLBACK="999" \
&& export CUDA_VER=$(echo ${CUDA_VERSION:-"${DEFAULT_CUDA_VERSION_FALLBACK}"} | cut -c1-4 | sed 's/\.//' ) \
&& export IDX=$( [ -x "$(command -v nvcc)" ] && echo "cu${CUDA_VER:-117}" || echo "cpu" ) \
&& echo "Detected CUDA version=${CUDA_VER} and IDX=${IDX}" \
# -----------------------------
## -----------------------------
&& echo "Handle tensorflow installation 1.x/2.x, cpu/gpu: https://www.tensorflow.org/install/source#gpu" \
&& ( $(grep -q "tf" <<< "${ARG_PROFILE_PYTHON}") && ( \
V=$($(grep -q "tf1" <<< "${ARG_PROFILE_PYTHON}") && echo "1" || echo "2" ) \
TF=$( [ "$V" == "1" ] && echo "tensorflow-gpu" || echo "tensorflow") \
&& echo "${TF}==${V}.*" > "/opt/utils/install_list_PY_tf${V}.pip" \
) || echo "Skipping tf install" ) \
# -----------------------------
## -----------------------------
&& echo "Handle pytorch installation 1.x only, cpu/gpu: https://pytorch.org/get-started/locally/" \
&& ( $(grep -q "torch" <<< "${ARG_PROFILE_PYTHON}") && ( \
echo "If CUDA version < 11.7, install pytorch 1.x, else install pytorch 2.x; if cuda doesn't exist, install pytorch 2.x" \
&& export CUDA_VER_TORCH="117" && V=$([[ "${CUDA_VER:-999}" -lt "${CUDA_VER_TORCH}" ]] && echo "torch<2" || echo "torch") \
&& pip install --no-cache-dir --root-user-action=ignore -U --pre "${V}" torchvision torchaudio --index-url "https://download.pytorch.org/whl/${IDX}" \
) || echo "Skipping pytorch install" ) \
# -----------------------------
## -----------------------------
&& echo "Handle paddle installation, cpu/gpu: https://www.paddlepaddle.org.cn/" \
&& ( $(grep -q "paddle" <<< "${ARG_PROFILE_PYTHON}") && ( \
URL_PYPI_PADDLE="https://www.paddlepaddle.org.cn/packages/stable/${IDX}/" \
&& PADDLE=$( [ -x "$(command -v nvcc)" ] && echo "paddlepaddle-gpu" || echo "paddlepaddle") \
&& pip install --no-cache-dir --root-user-action=ignore -U --pre --index-url ${URL_PYPI_PADDLE} "${PADDLE}" \
) || echo "Skip paddle install" ) \
# -----------------------------
## -----------------------------
# && [ "${PIP_FIND_LINKS+set}" != "set" ] && echo "PIP_FIND_LINKS is not set!" || echo "PIP_FIND_LINKS is set to: ${PIP_FIND_LINKS}" \
&& for profile in $(echo $ARG_PROFILE_PYTHON | tr "," "\n") ; do ( \
[ -f "/opt/utils/install_list_PY_${profile}.apt" ] && install_apt "/opt/utils/install_list_PY_${profile}.apt" || echo "apt install skipped for ${profile}" ; \
Expand All @@ -96,30 +97,30 @@ RUN set -eux \
&& pip freeze | awk -F= 'tolower($1) ~ /^nvidia-/ {print $1}' | xargs -r pip uninstall -y \
&& apt-get -qq update --fix-missing && apt-get -qq install -y --no-install-recommends --allow-change-held-packages libcusparselt0 libnccl2 libnccl-dev ; \
fi \
# -----------------------------
## -----------------------------
&& if echo "${ARG_PROFILE_GO}" | grep -q "base" ; then \
echo "Installing GO: ${ARG_PROFILE_GO}" && setup_GO ; \
else \
echo "Skip installing GO" ; \
fi \
# -----------------------------
## -----------------------------
&& if echo "${ARG_PROFILE_RUST}" | grep -q "base" ; then \
echo "Installing rust: ${ARG_PROFILE_RUST}" && setup_rust ; \
else \
echo "Skip installing rust" ; \
fi \
# -----------------------------
## -----------------------------
&& if echo "${ARG_PROFILE_JULIA}" | grep -q "base" ; then \
echo "Installing julia: ${ARG_PROFILE_JULIA}" && setup_julia ; \
else \
echo "Skip installing julia" ; \
fi \
# -----------------------------
## -----------------------------
&& if echo "${ARG_PROFILE_OCTAVE}" | grep -q "base" ; then \
echo "Installing Octave: ${ARG_PROFILE_OCTAVE}" && setup_octave ; \
else \
echo "Skip installing octave" ; \
fi \
# -----------------------------
## -----------------------------
&& echo "Clean up and display components version information..." \
&& list_installed_packages && install__clean
2 changes: 1 addition & 1 deletion docker_cuda/nvidia-cuda.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LABEL maintainer="postmaster@labnow.ai"
# Let NVIDIA docker ignore cuda requirement check
ENV NVIDIA_DISABLE_REQUIRE=1

# For cuda version 10.0, the image is solely serverd for legacy tensorflow 1.15, which requires python 3.7
# For cuda version 10.0, the image is solely served for legacy tensorflow 1.15, which requires python 3.7
# For tensorflow 2.x or torch, python>=3.9 is supported.
RUN set -eux && echo ${CUDA_VERSION} && nvcc --version \
# HACK & FIX: for some old version of NVIDIA docker images, sys python version is too old, update debpython
Expand Down
17 changes: 9 additions & 8 deletions tool.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -xu
set -eux

CI_PROJECT_NAME=${CI_PROJECT_NAME:-$GITHUB_REPOSITORY}
CI_PROJECT_BRANCH=${GITHUB_HEAD_REF:-"main"}
Expand All @@ -25,28 +25,29 @@ echo "--------> DOCKER_TAG_SUFFIX=${TAG_SUFFIX}"
build_image() {
echo "$@" ;
IMG=$1; TAG=$2; FILE=$3; shift 3; VER=$(date +%Y.%m%d.%H%M)${TAG_SUFFIX}; WORKDIR="$(dirname $FILE)";
docker build --compress --force-rm=true -t "${IMG_PREFIX_DST}/${IMG}:${TAG}" -f "$FILE" --build-arg "BASE_NAMESPACE=${IMG_PREFIX_SRC}" "$@" "${WORKDIR}" >&2
docker tag "${IMG_PREFIX_DST}/${IMG}:${TAG}" "${IMG_PREFIX_DST}/${IMG}:${VER}" >&2
docker build --compress --force-rm=true -t "${IMG_PREFIX_DST}/${IMG}:${TAG}" -f "$FILE" --build-arg "BASE_NAMESPACE=${IMG_PREFIX_SRC}" "$@" "${WORKDIR}"
docker tag "${IMG_PREFIX_DST}/${IMG}:${TAG}" "${IMG_PREFIX_DST}/${IMG}:${VER}"
echo "${IMG_PREFIX_DST}/${IMG}:${TAG}"
}

build_image_no_tag() {
echo "$@" ;
IMG=$1; TAG=$2; FILE=$3; shift 3; WORKDIR="$(dirname $FILE)";
docker build --compress --force-rm=true -t "${IMG_PREFIX_DST}/${IMG}:${TAG}" -f "$FILE" --build-arg "BASE_NAMESPACE=${IMG_PREFIX_SRC}" "$@" "${WORKDIR}" >&2
docker build --compress --force-rm=true -t "${IMG_PREFIX_DST}/${IMG}:${TAG}" -f "$FILE" --build-arg "BASE_NAMESPACE=${IMG_PREFIX_SRC}" "$@" "${WORKDIR}"
echo "${IMG_PREFIX_DST}/${IMG}:${TAG}"
}

alias_image() {
IMG_1=$1; TAG_1=$2; IMG_2=$3; TAG_2=$4; shift 4; VER=$(date +%Y.%m%d.%H%M)${TAG_SUFFIX};
docker tag "${IMG_PREFIX_DST}/${IMG_1}:${TAG_1}" "${IMG_PREFIX_DST}/${IMG_2}:${TAG_2}" >&2
docker tag "${IMG_PREFIX_DST}/${IMG_2}:${TAG_2}" "${IMG_PREFIX_DST}/${IMG_2}:${VER}" >&2
docker tag "${IMG_PREFIX_DST}/${IMG_1}:${TAG_1}" "${IMG_PREFIX_DST}/${IMG_2}:${TAG_2}"
docker tag "${IMG_PREFIX_DST}/${IMG_2}:${TAG_2}" "${IMG_PREFIX_DST}/${IMG_2}:${VER}"
}

push_image() {
KEYWORD="${1:-second}";
docker image prune --force && docker images | sort;
IMAGES=$(docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.CreatedSince}}" | grep "${KEYWORD}" | awk '{print $1 ":" $2}') ;
IMAGES=$(docker images --format "{{.Repository}}\t{{.Tag}}\t{{.CreatedSince}}" | grep "${KEYWORD}" | awk '{print $1 ":" $2}') ;
[ -n "${IMAGES}" ] || { echo "!! No images matched keyword: ${KEYWORD}"; return 1; }
echo "$DOCKER_REGISTRY_PASSWORD" | docker login "${REGISTRY_DST}" -u "$DOCKER_REGISTRY_USERNAME" --password-stdin ;
for IMG in $(echo "${IMAGES}" | tr " " "\n") ;
do
Expand All @@ -57,7 +58,7 @@ push_image() {
}

clear_images() {
KEYWORD=${1:-'days ago\|weeks ago\|months ago\|years ago'}; # if no keyword is provided, clear all images build days ago
KEYWORD=${1:-'days ago\|weeks ago\|months ago\|years ago'}; # if no keyword is provided, clear all images built days ago
IMGS_1=$(docker images | grep "${KEYWORD}" | awk '{print $1 ":" $2}') ;
IMGS_2=$(docker images | grep "${KEYWORD}" | awk '{print $3}') ;

Expand Down