-
Notifications
You must be signed in to change notification settings - Fork 5
/
_ink
executable file
·50 lines (37 loc) · 1.16 KB
/
_ink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -eo pipefail
[[ -z "$INK_DEBUG" ]] || set -x
DEFAULT_INK_PACKAGE=https://tools.airbyte.com/ink/${INK_VERSION}/ink-${INK_VERSION}.tar.gz
INK_PACKAGE="${INK_PACKAGE:-${DEFAULT_INK_PACKAGE}}"
DEFAULT_INK_IMAGE=ghcr.io/airbytehq/ink:${INK_VERSION}
INK_IMAGE="${INK_IMAGE:-${DEFAULT_INK_IMAGE}}"
INK_VENV_PATH=${INK_VENV_PATH:-.venv}
PYTHON_DEFAULT=$(which python || which python3)
PYTHON_CMD="${PYTHON_CMD:-${PYTHON_DEFAULT}}"
_error() {
echo "$@" 1>&2 && exit 1
}
_setup_env() {
if [[ ! -d "${INK_VENV_PATH}" ]]; then
echo "Setting up environment..."
"${PYTHON_CMD}" -m venv "${INK_VENV_PATH}"
source "${INK_VENV_PATH}/bin/activate"
pip install --quiet --upgrade pip
local cmd=()
echo "$INK_PACKAGE" | grep -qE "^(file:|[^:]+$)" && cmd+=(-e)
cmd+=("${INK_PACKAGE}")
pip install --quiet "${cmd[@]}"
else
source "${INK_VENV_PATH}/bin/activate"
fi
}
main() {
if [[ -z "$INK_USE_DOCKER" || -n "$INK_IN_DOCKER" ]]; then
_setup_env
ink "$@"
else
docker pull --quiet "$INK_IMAGE"
docker run --rm -v $(pwd):/stage -e INK_IN_DOCKER=1 "$INK_IMAGE" "$@"
fi
}
main "$@"