-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.sh
executable file
·54 lines (48 loc) · 1.19 KB
/
container.sh
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
#!/usr/bin/env bash
set -euo pipefail
set -x
# Load environment variables
source .devenv
# Parse command line arguments
PLATFORM="${RCCN_USR_DEV_PLATFORM}" # Default from .devenv
while [[ $# -gt 0 ]]; do
case $1 in
--platform=*)
PLATFORM="${1#*=}"
shift
;;
*)
break
;;
esac
done
# Default values
USERNAME="rosdev"
WORKSPACE="/home/rosdev/ros2_ws"
# Check if we should build from Dockerfile or use existing image
if [ -n "${RCCN_USR_DEV_CONTAINER_FILE:-}" ]; then
echo "Building container from $RCCN_USR_DEV_CONTAINER_FILE..."
docker build -t local-dev-container -f "$RCCN_USR_DEV_CONTAINER_FILE" .
CONTAINER_IMAGE="local-dev-container"
else
CONTAINER_IMAGE="$RCCN_USR_DEV_CONTAINER_IMAGE"
fi
# Check if we're running interactively
if [ -t 0 ]; then
INTERACTIVE_FLAGS="-it"
else
INTERACTIVE_FLAGS=""
fi
# Run the command in container
podman run \
--rm \
$INTERACTIVE_FLAGS \
--platform="$PLATFORM" \
--net=host \
-v "$(pwd):$WORKSPACE" \
-w "$WORKSPACE" \
-u "$(id -u):$(id -g)" \
--userns=keep-id \
--env "HOME=/home/rosdev" \
"$CONTAINER_IMAGE" \
bash -c "$*"