-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnzp
More file actions
executable file
·33 lines (28 loc) · 1.22 KB
/
nzp
File metadata and controls
executable file
·33 lines (28 loc) · 1.22 KB
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
#!/usr/bin/env bash
set -e
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
TOOLBOX_ROOT="$(cd "$(dirname "$0")" && pwd)"
IMAGE_NAME="nzp-toolbox:latest"
# Auto-build Docker image if absent.
if ! docker image inspect "$IMAGE_NAME" >/dev/null 2>&1; then
echo "[INFO] Docker image not found. Building..."
docker build --platform=linux/amd64 -t "$IMAGE_NAME" "$TOOLBOX_ROOT"
echo "-----------------------------------------"
fi
# Detect first-time setup and pull repos if needed
if [ ! -d "$TOOLBOX_ROOT/repos" ] || ! compgen -G "$TOOLBOX_ROOT/repos/*/.git" > /dev/null; then
echo "[INFO] Pulling repositories for first time use..."
docker run --platform=linux/amd64 --rm -i \
-v "$TOOLBOX_ROOT/config":/workspace/config \
-v "$TOOLBOX_ROOT/repos":/workspace/repos \
-v "$TOOLBOX_ROOT/python_envs":/workspace/python_envs \
"$IMAGE_NAME" fetch
echo "-----------------------------------------"
fi
# Run container with mounts and pass our arguments
docker run --platform=linux/amd64 --rm -i \
-v "$TOOLBOX_ROOT/config":/workspace/config \
-v "$TOOLBOX_ROOT/repos":/workspace/repos \
-v "$TOOLBOX_ROOT/python_envs":/workspace/python_envs \
"$IMAGE_NAME" \
"$@"