2024-05-10 00:18:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-05-10 01:55:59 +00:00
|
|
|
# Copyright (C) 2024 Bellande Robotics Sensors Research Innovation Center, Ronaldson Bellande
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2024-05-10 03:46:52 +00:00
|
|
|
# Get the directory of the script
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2024-05-10 00:18:45 +00:00
|
|
|
# Check user input
|
|
|
|
if [ "$1" = "ros1" ]; then
|
|
|
|
# Define the Dockerfile name and tag for ROS 1
|
2024-05-10 03:46:52 +00:00
|
|
|
DOCKERFILE="$DIR/../docker/Dockerfile.ros1"
|
2024-05-24 06:35:36 +00:00
|
|
|
IMAGE_NAME="bellande_web_api_packages_ros1"
|
2024-05-10 00:18:45 +00:00
|
|
|
elif [ "$1" = "ros2" ]; then
|
|
|
|
# Define the Dockerfile name and tag for ROS 2
|
2024-05-10 03:46:52 +00:00
|
|
|
DOCKERFILE="$DIR/../docker/Dockerfile.ros2"
|
2024-05-24 06:35:36 +00:00
|
|
|
IMAGE_NAME="bellande_web_api_packages_ros2"
|
2024-05-10 00:18:45 +00:00
|
|
|
else
|
|
|
|
echo "Invalid input. Please provide either 'ros1' or 'ros2'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
TAG="latest" # Change this to the desired tag for your Docker image
|
|
|
|
|
2024-05-10 03:46:52 +00:00
|
|
|
# Navigate to the directory containing the Dockerfile
|
|
|
|
cd "$DIR/../docker" || exit
|
|
|
|
|
2024-05-10 00:18:45 +00:00
|
|
|
# Build the Docker image
|
2024-05-10 03:46:52 +00:00
|
|
|
docker build -t $IMAGE_NAME:$TAG -f $DOCKERFILE "$DIR/../"
|
2024-05-10 00:18:45 +00:00
|
|
|
|
|
|
|
# Check if the image was built successfully
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Docker image $IMAGE_NAME:$TAG built successfully."
|
|
|
|
else
|
|
|
|
echo "Error: Failed to build Docker image."
|
|
|
|
fi
|