-
-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathdocker_latest.sh
More file actions
executable file
·55 lines (44 loc) · 1.82 KB
/
docker_latest.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.82 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Source shared docker helper functions
# shellcheck source=docker/common.sh
source "$(dirname "$0")/docker/common.sh"
# Determine an initial Docker image (allow override via DOCKER_LATEST_IMAGE)
DOCKER_IMAGE="${DOCKER_LATEST_IMAGE:-tlaurion/heads-dev-env:latest}"
usage() {
cat <<'USAGE'
Usage: ./docker_latest.sh [COMMAND...]
Run the maintainer "latest" image (or a pinned digest if configured).
Environment:
DOCKER_LATEST_IMAGE=... Override the image/tag to run
DOCKER_LATEST_DIGEST=... Pin to a specific digest (sha256:...)
HEADS_ALLOW_UNPINNED_LATEST=1 Allow unpinned :latest without prompting
HEADS_DISABLE_USB=1 Disable USB passthrough
HEADS_X11_XAUTH=1 Force mounting ~/.Xauthority
Examples:
./docker_latest.sh
DOCKER_LATEST_DIGEST=sha256:... ./docker_latest.sh
USAGE
}
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
usage
exit 0
fi
trap 'echo "Script interrupted. Exiting..."; exit 1' SIGINT
# Resolve pinned digest (env var preferred, repository file fallback), and prompt if using unpinned :latest
DOCKER_IMAGE="$(resolve_docker_image "$DOCKER_IMAGE" "DOCKER_LATEST_DIGEST" "DOCKER_LATEST_DIGEST" "1")"
# If resolve_docker_image returned empty for any reason, abort
if [ -z "${DOCKER_IMAGE}" ]; then
echo "Error: failed to resolve Docker image; aborting." >&2
exit 1
fi
echo "Using latest image: $DOCKER_IMAGE" >&2
echo "" >&2
# Only perform host-side side-effects when executed directly (not when sourced)
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
require_docker || exit $?
# Clean up host processes holding USB devices first (if applicable)
kill_usb_processes
# Execute the docker run command with the provided parameters
# Delegate to shared run_docker so all docker_* scripts share identical device/X11/KVM handling
run_docker "$DOCKER_IMAGE" "$@"
fi