-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·82 lines (75 loc) · 2.38 KB
/
build.sh
File metadata and controls
executable file
·82 lines (75 loc) · 2.38 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# Copyright 2025 Ekumen, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
# Default values for configuration
IMAGE_NAME="ekumenlabs/ros2-testing-workshop-roscon-es-25"
ROS_DISTRO="jazzy"
PLATFORM="linux/amd64"
TAG="${ROS_DISTRO}"
SCRIPT_FOLDER_PATH="$(cd "$(dirname "$0")"; pwd)"
CONTEXT_FOLDER_PATH="$(cd "$(dirname "$0")"; cd .. ; pwd)"
DOCKERFILE_PATH=$SCRIPT_FOLDER_PATH/Dockerfile
# Helper Function
function print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Builds the Docker image for the ROS 2 workshop."
echo
echo "Options:"
echo " -n, --name <name> Set the image name (default: ${IMAGE_NAME})"
echo " -t, --tag <tag> Set the image tag (default: ${TAG})"
echo " -p, --platform <platform> Set the target platform (default: ${PLATFORM})"
echo " -h, --help Show this help message"
}
# Argument Parsing
while [[ $# -gt 0 ]]; do
case $1 in
-n|--name)
IMAGE_NAME="$2"
shift; shift
;;
-t|--tag)
TAG="$2"
shift; shift
;;
-p|--platform)
PLATFORM="$2"
shift; shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $1"
print_usage
exit 1
;;
esac
done
# Check for Docker permissions instead of hardcoding 'sudo'
if ! docker info > /dev/null 2>&1; then
echo -e "\n\e[31mError:\e[0m Docker is not running or you don't have permission to use it."
echo "Please ensure the Docker daemon is running."
echo "To fix permission issues, you can either:"
echo " 1. Add your user to the 'docker' group: \e[33msudo usermod -aG docker ${USER}\e[0m (requires logout/login)"
echo " 2. Run this script with sudo: \e[33msudo $0\e[0m"
exit 1
fi
echo "Building Docker image: ${IMAGE_NAME}:${TAG}"
docker build \
--platform "${PLATFORM}" \
-f "${DOCKERFILE_PATH}" \
-t "${IMAGE_NAME}:${TAG}" \
"${CONTEXT_FOLDER_PATH}"