diff --git a/build/build_images.sh b/build/build_images.sh new file mode 100755 index 0000000000000000000000000000000000000000..e37ce899065eeb157dbc654be7dd4352dd2bb843 --- /dev/null +++ b/build/build_images.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Set environment variables +export VERSION="2.2" +export DOCKERHUB_REPO="alexdecb" + +# Function to build image +build_image() { + local image_name="$1" + local folder_name="$2" + + echo "Building ${image_name}..." + docker build -t "${DOCKERHUB_REPO}/${image_name}:${VERSION}" -f "./build/${folder_name}/Dockerfile" . +} + +# Function to push image +push_image() { + local image_name="$1" + + echo "Pushing ${image_name}..." + docker push "${DOCKERHUB_REPO}/${image_name}:${VERSION}" +} + +# Option 1: Build image +if [ "$1" == "build" ]; then + build_image "l2sm-switch" "switch" + build_image "l2sm-controller" "controller" + build_image "l2sm-operator" "operator" + echo "Images have been built successfully." + +# Option 2: Push image +elif [ "$1" == "push" ]; then + push_image "l2sm-switch" + push_image "l2sm-controller" + push_image "l2sm-operator" + echo "Images have been pushed successfully." + +# Option 3: Build and push image +elif [ "$1" == "build_push" ]; then + build_image "l2sm-switch" "switch" + push_image "l2sm-switch" + build_image "l2sm-controller" "controller" + push_image "l2sm-controller" + build_image "l2sm-operator" "operator" + push_image "l2sm-operator" + echo "Images have been built and pushed successfully." + +# Invalid option +else + echo "Invalid option. Please use 'build', 'push', or 'build_push'." + exit 1 +fi diff --git a/build/switch/Dockerfile b/build/switch/Dockerfile index 3d62217b527da9ee968ed9f1d60344c561f9efb4..8e96044d250cb3d219b9c665d4cef1f003f89d08 100644 --- a/build/switch/Dockerfile +++ b/build/switch/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /usr/src/l2sm-switch COPY ./src/switch/ ./build/switch/build-go.sh ./ -RUN ./build-go.sh +RUN chmod +x ./build-go.sh && ./build-go.sh FROM ubuntu:latest