forked from ayufan/pve-backup-server-dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.bash
More file actions
executable file
·37 lines (29 loc) · 797 Bytes
/
Copy pathenv.bash
File metadata and controls
executable file
·37 lines (29 loc) · 797 Bytes
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
#!/bin/bash
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR/"
set -eo pipefail
TAG=pve-backup-build-env
TARGET=build
IMAGE="$TAG"
NAME="$IMAGE-run"
if ! docker inspect "$IMAGE" &>/dev/null; then
echo ">> Building..."
docker build -f "dockerfiles/Dockerfile.build" -t "$TAG" --target toolchain "."
IMAGE="$TAG"
fi
if [[ $(docker inspect -f '{{.State.Status}}' "$NAME" 2>/dev/null) == "running" ]]; then
echo ">> Re-using..."
if [[ $# -eq 0 ]]; then
set -- "bash"
fi
docker exec -it "$NAME" "$@" || true
else
docker rm -f "$NAME" &>/dev/null || true
echo ">> Starting..."
docker run -it \
-w "/src" \
-v "$PWD:/src" \
-v "$PWD/tmp/root:/root" \
--name="$NAME" "$IMAGE" "$@" || true
fi
echo ">> Done."