#!/bin/bash # Safely execute this bash script # e exit on first failure # x all executed commands are printed to the terminal # u unset variables are errors # a export all variables to the environment # E any trap on ERR is inherited by shell functions # -o pipefail | produces a failure code if any stage fails set -Eeuoxa pipefail LOCAL_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" for ARGUMENT in "$@" do KEY=$(echo $ARGUMENT | cut -f1 -d=) KEY_LENGTH=${#KEY} VALUE="${ARGUMENT:$KEY_LENGTH+1}" export "$KEY"="$VALUE" done echo "Run mode is: $RUN_MODE" echo "Model passed is: $LOCAL_MODEL_NAME" docker buildx build --platform=linux/amd64 -t ldr . docker run -it --rm -p 7860:7860 --platform=linux/amd64 -v $LOCAL_DIRECTORY/output-data:/code/data -e RUN_MODE=$RUN_MODE -e LOCAL_MODEL_NAME=$LOCAL_MODEL_NAME ldr python app.py