main.sh: Extends Docker build with component options

Enhances the Docker build process, allowing users to specify whether to include demo content.

It also gives the possibility to inject latest components.
This commit is contained in:
Carlos Santos 2025-10-17 11:06:10 +02:00
parent 7b76d33377
commit 4e65ca2d04

50
meet.sh
View File

@ -549,32 +549,36 @@ clone_meet_pro() {
# Build Docker image # Build Docker image
build_docker() { build_docker() {
local image_name="$1" local image_name="$1"
local is_demos=false # Remove first argument (image name)
shift || true
# Validate arguments
if [ -z "$image_name" ]; then if [ -z "$image_name" ]; then
echo -e "${RED}Error: You need to specify an image name${NC}" echo -e "${RED}Error: You need to specify an image name${NC}"
echo -e "${YELLOW}Usage: ./meet.sh build-docker <image-name> [--demos]${NC}" echo -e "${YELLOW}Usage: ./meet.sh build-docker <image-name> [--demos]${NC}"
exit 1 exit 1
fi fi
# Parse remaining arguments for flags # Parse flags
shift # Remove image_name from arguments local is_demos=false
for arg in "$@"; do local use_latest_components=false
case "$arg" in for _arg in "$@"; do
case "$_arg" in
--demos) --demos)
is_demos=true is_demos=true
;; ;;
--with-latest-components)
use_latest_components=true
;;
*)
# ignore unknown flags for forward compatibility
;;
esac esac
done done
echo -e "${BLUE}=====================================${NC}" # Prepare metadata
echo -e "${BLUE} Building Docker Image${NC}"
echo -e "${BLUE}=====================================${NC}"
echo
local final_image_name="$image_name" local final_image_name="$image_name"
local base_href="/" local base_href="/"
if [ "$is_demos" = true ]; then if [ "$is_demos" = true ]; then
final_image_name="${image_name}-demos" final_image_name="${image_name}-demos"
base_href="/openvidu-meet/" base_href="/openvidu-meet/"
@ -583,11 +587,21 @@ build_docker() {
echo -e "${GREEN}Building production image: $final_image_name${NC}" echo -e "${GREEN}Building production image: $final_image_name${NC}"
fi fi
echo -e "${GREEN}Using BASE_HREF: $base_href${NC}" echo -e "${BLUE}=====================================${NC}"
export BUILDKIT_PROGRESS=plain && \ echo -e "${BLUE} Building Docker Image${NC}"
docker build --pull --no-cache --rm=true -f meet-ce/docker/Dockerfile -t "$final_image_name" --build-arg BASE_HREF="$base_href" . echo -e "${BLUE}=====================================${NC}"
echo
if [ $? -eq 0 ]; then # Optionally install latest components to avoid local dist symlink inside image
if [ "$use_latest_components" = true ]; then
echo "🔧 Installing latest openvidu-components-angular..."
pnpm --filter @openvidu-meet/frontend install openvidu-components-angular@next
fi
echo -e "${GREEN}Using BASE_HREF: $base_href${NC}"
export BUILDKIT_PROGRESS=plain
if docker build --pull --no-cache --rm=true -f meet-ce/docker/Dockerfile -t "$final_image_name" --build-arg BASE_HREF="$base_href" .; then
echo echo
echo -e "${GREEN}✓ Docker image '$final_image_name' built successfully!${NC}" echo -e "${GREEN}✓ Docker image '$final_image_name' built successfully!${NC}"
else else
@ -595,6 +609,12 @@ build_docker() {
echo -e "${RED}✗ Failed to build Docker image '$final_image_name'${NC}" echo -e "${RED}✗ Failed to build Docker image '$final_image_name'${NC}"
exit 1 exit 1
fi fi
# Restore local link if we temporarily installed latest components
if [ "$use_latest_components" = true ]; then
echo "🔧 Restoring openvidu-components-angular to local dist link..."
pnpm --filter @openvidu-meet/frontend install openvidu-components-angular@link:../../../openvidu/openvidu-components-angular/dist/openvidu-components-angular
fi
} }
# Main script logic # Main script logic